Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add comments with type for exports #46

Closed
wants to merge 1 commit into from
Closed

Conversation

tkers
Copy link
Member

@tkers tkers commented Mar 9, 2019

Just a little experiment, but it would be nice to be able to enable something like this in the output.

  • Pass the TypedModule (from infer) to compile, so type info becomes accessible
  • Using (exp.value.info as any).type to get the type of an expression, because we do not have an explicit Node<Untyped> yet.
  • The estree types are not fully compatible with recast, in particular the comments work differently. Where estree expects leadingComments: [] and trailingComments: [] on the Expression itself, recast uses a comments: [] fields and checks for a leading or trailing flag inside the Comment (so some as JS.ExpressionStatement hacks were needed).

Result is that

(export foo 42)

compiles to

// type: number
module.exports.foo = 42;

@tkers tkers closed this Mar 22, 2019
@tkers tkers deleted the comment-export-types branch March 22, 2019 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant