Major rewrite. I want to put here some stubs for the notes:
-
Explain
TypeScript
package structure:-
it tries to follow original
typescript/typescript
project structure. -
Internal
modules are modules which expose typescript implementation internals which seems to be really useful. -
Contrib
subpackage contains additions - for clarity -
Bindings to
is*
are usually renamed toas*
functions which returnMaybe t
wheret
is narrowed type -
Node r
- provide info about interfaces access model. -
Add info about immutability of the Program from the checker and the decision behind "pure" bindings.
A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
-
Provide a way to work with TypeScript types declarations.
Currently we are in a somewhat inconsistent state. On the one hand this codebase is very rough in a many places and it is developed thanks to the live experimentation and direct source browsing of the typescript compiler. On the other hand we successfully test and use it against quite a large codegen projects.
As a main battlefield we have choosen purescript-react-basic-mui
so please check this project for an extended example.
API of this library consists of three layers.
-
We have semivisitor API build upon TypeScript compiler API and provided by
ReadDTS.ts
andReadDTS.purs
. -
We have an opinionated minimal AST which represents TypeScript types declarations. You can find it in
ReadDTS/AST.purs
. Initially this AST contains unresolved refreneces to other types which are filled during unfolding done by effectfullAST.coalgebra
. -
Finally we have
ReadDTS/Instantiation.purs
module (it should be renamed toSpecialization.purs
) which provides an AST for an instantiated type from a given type declaration.
This is directed and acyclical dependency graph of modules so you can use any previous layer without bothering about the next step ASTs design.
Please, consider Test.ReadDTS.Instantiation as a form of a short guide for the top layer of this lib.
Currently we are runnig only test/ReadDTS/Instantiation.purs
as a part of main suite.
$ spago test
-
This library has started as an attempt to fix some bugs in
purescript-readts
. It has diverged into a separate lib and till its full maturation we want to keep it separate and not propose any merges. -
Initial developement was funded by lambdaterms.com
- Typescript compiler API - using the type checker
- purescript-tsd-gen - Generate DTS from purescript, the reverse of this repository.
- Generate json-schema from your Typescript sources: typescript-json-schema. This is useful to see how the typescript compiler works and which information can be extracted from it.