Repository navigation
Fix object literal method with bigint property name omitted in declaration emit (#61769) - #65392
Open
Rudransh Shekhar (rudy-07) wants to merge 1 commit into
Open
Rudransh Shekhar (rudy-07) wants to merge 1 commit into
Rudransh Shekhar (rudy-07) wants to merge 1 commit into
Conversation
… declaration emit
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #61769
Summary of the Problem
In TypeScript, defining a method on an object literal using a
bigintliteral property name (for example,{ 0n() { return true; } }) omitted the method from the generated.d.tsdeclaration file when--declarationwas enabled. In contrast, class methods with bigint literal property names (such asclass C { 0n() {} }) were emitted properly.Additionally, checking an object literal against a type requiring a bigint literal method resulted in a false-positive TS2741 error because the binder did not register the method name properly on the object literal symbol table.
Root Cause
Two separate locations were missing handling for
KindBigIntLiteral:Binder Declaration Naming (
tsc/internal/ast/utilities.go):IsPropertyNameLiteraldid not includeKindBigIntLiteral.IsPropertyNamedid not includeKindBigIntLiteralandKindNoSubstitutionTemplateLiteral.getDeclarationNameevaluated object literal method definitions with bigint names as missing declaration names, assigning themInternalSymbolNameMissing("\xFEmissing"). This prevented the property from being recorded under its proper symbol name inresolvedType.getProperties().Declaration Node Builder (
tsc/internal/checker/nodebuilderimpl.go):classifyPropertyName,createPropertyNameNodeForIdentifierOrLiteral, andgetPropertyNameNodeForSymbolFromNameTypeonly handled string and numeric literal property names, falling back to identifier nodes or missing node generation for bigint literals.Changes Made
IsPropertyNameLiteralintsc/internal/ast/utilities.goto recognizeast.KindBigIntLiteral.IsPropertyNameintsc/internal/ast/utilities.goto includeast.KindBigIntLiteralandast.KindNoSubstitutionTemplateLiteral.classifyPropertyNameintsc/internal/checker/nodebuilderimpl.goto classify bigint literal names aspropertyNameClassLiteralOrUnique.createPropertyNameNodeForIdentifierOrLiteralandgetPropertyNameNodeForSymbolFromNameTypeintsc/internal/checker/nodebuilderimpl.goto constructast.KindBigIntLiteralAST nodes when building declaration property names.tsc/testdata/tests/cases/compiler/objectLiteralBigIntMethodDeclarationEmit.tscovering object literal methods with bigint property names in declaration emit, return type inference, interface matching, and class method parity.enumWithBigint.types,bigintPropertyName.*).AI Disclosure
In accordance with CONTRIBUTING.md guidelines on AI assistance: this patch was developed with the assistance of an AI coding agent. The code changes, root cause analysis, and test baselines were reviewed, built, and verified locally by the contributor before submission.