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

Use NodeFactory to create and update nodes #56

Merged
merged 1 commit into from
Oct 26, 2020
Merged

Conversation

edsrzf
Copy link
Collaborator

@edsrzf edsrzf commented Oct 24, 2020

Most ts.create* and ts.update* functions are deprecated as of TypeScript 4.0. The current plan is to emit noisier and noisier warnings with each version until the deprecated functions are removed in 4.3.

See this pull request for more details: microsoft/TypeScript#35282

Some method signatures and names have changed slightly.

The easy way to update is to use the global ts.factory object. TypeScript transformations also have access to a NodeFactory in their transformation contexts.

Note that we still use the deprecate getMutableClone function because its replacement is not included in the TypeScript declarations. See microsoft/TypeScript#40507

I found uses of deprecated functions by searching code for the terms ts.create and ts.update. This turned up some false positives, such as calls to ts.createPrinter, which I ignored.

Most ts.create* and ts.update* functions are deprecated as of TypeScript 4.0. The
current plan is to emit noiser and noisier warnings with each version
until the deprecated functions are removed in 4.3.

See this pull request for more details:
microsoft/TypeScript#35282

Some method signatures and names have changed slightly.

The easy way to update is to use the global ts.factory object.
TypeScript transformations also have access to a NodeFactory in their
transformation contexts.

Note that we still use the deprecate getMutableClone function because
its replacement is not included in the TypeScript declarations. See
microsoft/TypeScript#40507
sourceText: string,
options: Options,
): string {
const sourceFile = ts.createSourceFile(fileName, sourceText, ts.ScriptTarget.Latest, true);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed we were creating a new source file here when we could have passed through the one given to run, and couldn't see a reason for doing that.

sourceText: string,
force = false,
) {
const sourceFile = ts.createSourceFile(fileName, sourceText, ts.ScriptTarget.Latest, true);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor

@Rudeg Rudeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@Rudeg Rudeg merged commit 8c1f8c1 into airbnb:master Oct 26, 2020
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.

2 participants