Skip to content

Lock down computed names in object literals and classes under --isolatedDeclarations #58596

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 6 commits into from
May 22, 2024

Conversation

weswigham
Copy link
Member

Fixes #58490 - an error is now always emitted on computed names in classes and object literals under --isolatedDeclarations. Workarounds and carve-outs for builtin symbols, some new syntactic form, or locally bound unique symbols are followups~

cc @dragomirtitian

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels May 20, 2024
@weswigham weswigham requested a review from jakebailey May 21, 2024 22:33
@@ -351,7 +351,7 @@ export function createSyntacticTypeNodeBuilder(options: CompilerOptions, resolve
}
else if (prop.name.kind === SyntaxKind.ComputedPropertyName) {
const expression = prop.name.expression;
if (!isPrimitiveLiteralValue(expression, /*includeBigInt*/ false) && !isEntityNameExpression(expression)) {
if (!isPrimitiveLiteralValue(expression, /*includeBigInt*/ false)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is also code in typeFromObjectLiteral that is not effectively unused. isNonNarrowedBindableName also probably becomes useless since we can now syntactically determine if the computed property is valid so it can probably be removed from the resolver.

@dragomirtitian
Copy link
Contributor

@weswigham Also fixes #58533

@weswigham weswigham merged commit b682ed4 into microsoft:main May 22, 2024
28 checks passed
@weswigham weswigham deleted the isolated-computed-names branch May 22, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[isolatedDeclarations][5.5] Disagreement between transpileDeclaration API and typechecker on Symbol.iterator as computed property
4 participants