-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Make most current Node factory functions public #13825
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
Conversation
src/compiler/factory.ts
Outdated
| const name = <Identifier>createNode(SyntaxKind.Identifier, location); | ||
| /** Create a unique name based on the supplied text. */ | ||
| export function createUniqueName(text: string): Identifier { | ||
| const name = createIdentifier(""); |
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.
createIdentifier(text) ?
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 don't want to call escapeIdentifier on text, which is the default behavior of createIdentifier.
|
👍 |
sandersn
left a comment
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.
Couple of cosmetic comments.
src/compiler/factory.ts
Outdated
| // Utilities | ||
|
|
||
| function asName(name: string): Identifier; | ||
| function asName(name: Identifier): Identifier; |
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 string | Identifier covers both the string and Identifier overloads. Are they just there because they are easier to understand for people who don't know about union types?
src/compiler/factory.ts
Outdated
| * Associates a node with the current transformation, initializing | ||
| * various transient transformation properties. | ||
| * | ||
| * @param node The node. |
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.
These @param node The nodes are low value (as are a lot of the others), so I'd delete them.
This change makes a majority of our current Node factory functions a part of our public API. In addition, I have made a few API changes to make the API more consistent and ensure the public API is resilient to future changes.
The major change here involves the removal of the optional
locationparameter from most factory functions. This is due to the fact that anyNodeis aTextRange, and it would be very difficult to add overloads for if/when new members are added and still be able to distinguish between a validNodefor a new overload vs. an optionallocation. To continue to support the update pattern when visiting nodes, I have moved the operation that copies the original node'slocationto theupdateNodefunction infactory.ts.Fixes #13765