Closed rrdelaney closed 7 years ago
We should process import statements to be modules.
If there is a known binding in reasonml-community, transform the import into aliasing from that. Error on absolute imports without known modules.
For relative imports, use our own module transforming logic and assumer ReasonablyTyped will also process it.
For example, with the statement:
import type { $Request } from 'express'
we should look at the express bindings and emit:
type request = Express.Request.t
based on the following code: https://github.com/reasonml-community/bs-express/blob/master/src/express.re#L21-L22
For a local import such as:
import type { myThing } from './thing'
should be transformed to:
type myThing = Thing.myThing
You'll probably need to match on import statements in statement_to_program, and create a new BsDecl variant, then finally the output in declaration_to_code.
statement_to_program
BsDecl
declaration_to_code
We should process import statements to be modules.
Spec
If there is a known binding in reasonml-community, transform the import into aliasing from that. Error on absolute imports without known modules.
For relative imports, use our own module transforming logic and assumer ReasonablyTyped will also process it.
For example, with the statement:
we should look at the express bindings and emit:
based on the following code: https://github.com/reasonml-community/bs-express/blob/master/src/express.re#L21-L22
For a local import such as:
should be transformed to:
Implementation details
You'll probably need to match on import statements in
statement_to_program
, and create a newBsDecl
variant, then finally the output indeclaration_to_code
.