Skip to content

When source file is redirected, set the prototype correctly in node factory #48862

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

Merged
merged 1 commit into from
May 4, 2022

Conversation

sheetalkamat
Copy link
Member

Fixes #48039

@merceyz
Copy link

merceyz commented Apr 27, 2022

This should also close #41717 since #44554 was closed in favour of this one.

@@ -5275,7 +5275,7 @@ namespace ts {
hasNoDefaultLib: boolean,
libReferences: readonly FileReference[]
) {
const node = baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile) as Mutable<SourceFile>;
const node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile)) as Mutable<SourceFile>;
Copy link
Member

Choose a reason for hiding this comment

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

Is setting the prototype pretty typical in factory functions and whatnot @rbuckton?

Copy link
Contributor

Choose a reason for hiding this comment

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

We generally don't, but apparently we use Object.create in program.ts for redirected source files.

Copy link
Contributor

@rbuckton rbuckton left a comment

Choose a reason for hiding this comment

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

I'm concerned with the fact redirection uses Object.create to wrap an existing source file because its easily overlooked. However, since this is already an existing behavior this change seems fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot read property 'get' of undefined – file.pragmas.get("jsximportsource") in getJSXImplicitImportBase
5 participants