-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Inline const enum in import equals declaration #46664
base: main
Are you sure you want to change the base?
Conversation
@@ -162,7 +162,7 @@ namespace ts { | |||
const left = createExpressionFromEntityName(factory, node.left); | |||
// TODO(rbuckton): Does this need to be parented? | |||
const right = setParent(setTextRange(factory.cloneNode(node.right), node.right), node.right.parent); | |||
return setTextRange(factory.createPropertyAccessExpression(left, right), node); | |||
return setOriginalNode(setTextRange(factory.createPropertyAccessExpression(left, right), node), 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.
transformers/ts.ts
replaces import equals entity names with synthetic variable declarations + property access:
TypeScript/src/compiler/transformers/ts.ts
Line 2999 in 766e83f
const moduleReference = createExpressionFromEntityName(factory, node.moduleReference as EntityName); |
I experimented with resolving the synthetic property access, but settled on saving and resolving the original entity name instead?
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.
This needs some dedicated tests (I don't see one testing the issue described in the OP) and a merge to resolve the conflicts.
Do you want to keep working on this? Otherwise I'd like to close it to reduce the number of open PRs. |
@@ -38,7 +38,7 @@ var o = { | |||
1: true | |||
}; | |||
var a = 1 /* A */; | |||
var a1 = 1 /* "A" */; | |||
var a1 = 1 /* A */; |
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.
why changed?
I think it caused by following to:
var a1 = G["A"]; |
Currently we elide the enum declaration but not the import equals, which is an unavoidable reference error:
Base
Head
Fixes #16671 (comment)