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
Add declarations for more of @babel/types exports #10504
Add declarations for more of @babel/types exports #10504
Conversation
`// export function assert${typeName}(node: object | null | undefined, opts?: object | null): asserts ${ | ||
result === "boolean" ? "node" : result | ||
};` | ||
); | ||
} | ||
|
||
lines.push( |
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 think this whole thing would be much nicer to modify if there was, say, a typescript.template.d.ts
file that is complete enough to be typechecked and with placeholder comments / types for where the generated types should get injected; the generator script then just needs to slurp the template and edit it.
It'd also get us prettier for free.
937a656
to
b60ec41
Compare
This adds lots of missing declarations to the types of @babel/types, including many utility functions useful to plugin authors. With the typescript types, I tried to make them as useful as possible for control flow analysis / inference, but Flow doesn't seem to support overloads and I'm not as familiar with it anyway so it has simpler types.
b60ec41
to
6e8ad67
Compare
CircleCI's build failed.... because it ran out of memory? o_O
|
Yeah it's flaky |
|
||
lines.push( | ||
`export function is${typeName}(node: object | null | undefined, opts?: object | null): ${result};`, | ||
// TypeScript 3.7: https://github.com/microsoft/TypeScript/pull/32695 will allow assert declarations |
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.
We can use typesVersions to publish typings for typescript <3.7 and typescript >=3.7 at the same time, but we'll need to generate types twice.
I want to refactor the typescript generation to use .d.ts files as templates (to make it much easier to get editor feedback while modifying them) so I can try to do that at the same time.
This adds lots of missing declarations to the types of @babel/types,
including many utility functions useful to plugin authors.
With the typescript types, I tried to make them as useful as possible
for control flow analysis / inference, but Flow doesn't seem to
support overloads and I'm not as familiar with it anyway so it has
simpler types.