-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat: output type declaration #118
Conversation
@@ -7,6 +7,7 @@ export type ReactRenderConfig = FrameworkRenderConfig & { | |||
script?: ScriptKind; | |||
target?: ScriptTarget; | |||
module?: ModuleKind; | |||
declaration?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably a more readable or understandable name for this param. Maybe like exportTypeDeclarations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following the naming convention from TypeScript, but you are right that it isn't very descriptive. I'll change to something else.
// createProgram is less performant than transpileModule. | ||
// createProgram should only be used when necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is written more like an either-or, rather than a 'don't generate d.ts files if we don't need to, it's an expensive operations'.
tmpFile.removeCallback(); | ||
tmpDir.removeCallback(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be handled in a try-catch-finally to ensure we do our best effort to release any resources we're grabbing along the way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, checking the source it looks like these could throw errors. Looks like tmp.fileSync
and tmp.dirSync
could throw errors as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I mean if the fs module throws, then that seems reasonable that we didn't release some handle. I think more likely if our config or import code causes createProgram to throw then we should probably do some cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I've updated so that the tmp files should always be cleaned up.
e5b46c9
to
b1a9e66
Compare
b1a9e66
to
a8db227
Compare
This reverts commit 9db8bdc.
This reverts commit 9db8bdc.
React.Element
JSX.Element
was causing errors when trying to compile type declarationsI used
ts.createProgram
to compile the type declarations. Our existing solution ofts.transpileModule
does not support creating type declarations.ts.createProgram
requires the source to be written to the filesystem.ts.createProgram
is much less performant thants.transpileModule
sots.createProgram
is only used when necessary.