Make most current Node factory functions public#13825
Merged
Merged
Conversation
mhegazy
reviewed
Feb 2, 2017
| 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(""); |
Contributor
Author
There was a problem hiding this comment.
We don't want to call escapeIdentifier on text, which is the default behavior of createIdentifier.
|
👍 |
sandersn
approved these changes
Feb 3, 2017
Member
sandersn
left a comment
There was a problem hiding this comment.
Couple of cosmetic comments.
| // Utilities | ||
|
|
||
| function asName(name: string): Identifier; | ||
| function asName(name: Identifier): Identifier; |
Member
There was a problem hiding this comment.
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?
| * Associates a node with the current transformation, initializing | ||
| * various transient transformation properties. | ||
| * | ||
| * @param node The node. |
Member
There was a problem hiding this comment.
These @param node The nodes are low value (as are a lot of the others), so I'd delete them.
mhegazy
approved these changes
Feb 6, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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