Skip to content

purescript-codegen/purescript-read-dts

Repository files navigation

purescript-read-dts

Status

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 to as* functions which return Maybe t where t 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'

Old docs for reference during rewrite:


Provide a way to work with TypeScript types declarations.

Status

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.tsand ReadDTS.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 effectfull AST.coalgebra.

  • Finally we have ReadDTS/Instantiation.purs module (it should be renamed to Specialization.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.

Testing

Currently we are runnig only test/ReadDTS/Instantiation.purs as a part of main suite.

$ spago test

Credits

  • 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

Useful links

About

Provide a way to work with TypeScript types declarations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published