Skip to content

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
microsoft:mainfrom
rudy-07:fix-61769-bigint-literal-dts-emit
Open

Rudransh Shekhar (rudy-07) wants to merge 1 commit into
microsoft:mainfrom
rudy-07:fix-61769-bigint-literal-dts-emit

Conversation

@rudy-07

Copy link
Copy Markdown

Fixes #61769

Summary of the Problem

In TypeScript, defining a method on an object literal using a bigint literal property name (for example, { 0n() { return true; } }) omitted the method from the generated .d.ts declaration file when --declaration was enabled. In contrast, class methods with bigint literal property names (such as class 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:

  1. Binder Declaration Naming (tsc/internal/ast/utilities.go):

    • IsPropertyNameLiteral did not include KindBigIntLiteral.
    • IsPropertyName did not include KindBigIntLiteral and KindNoSubstitutionTemplateLiteral.
    • As a result, getDeclarationName evaluated object literal method definitions with bigint names as missing declaration names, assigning them InternalSymbolNameMissing ("\xFEmissing"). This prevented the property from being recorded under its proper symbol name in resolvedType.getProperties().
  2. Declaration Node Builder (tsc/internal/checker/nodebuilderimpl.go):

    • classifyPropertyName, createPropertyNameNodeForIdentifierOrLiteral, and getPropertyNameNodeForSymbolFromNameType only handled string and numeric literal property names, falling back to identifier nodes or missing node generation for bigint literals.

Changes Made

  • Updated IsPropertyNameLiteral in tsc/internal/ast/utilities.go to recognize ast.KindBigIntLiteral.
  • Updated IsPropertyName in tsc/internal/ast/utilities.go to include ast.KindBigIntLiteral and ast.KindNoSubstitutionTemplateLiteral.
  • Extended classifyPropertyName in tsc/internal/checker/nodebuilderimpl.go to classify bigint literal names as propertyNameClassLiteralOrUnique.
  • Updated createPropertyNameNodeForIdentifierOrLiteral and getPropertyNameNodeForSymbolFromNameType in tsc/internal/checker/nodebuilderimpl.go to construct ast.KindBigIntLiteral AST nodes when building declaration property names.
  • Added comprehensive compiler regression test in tsc/testdata/tests/cases/compiler/objectLiteralBigIntMethodDeclarationEmit.ts covering object literal methods with bigint property names in declaration emit, return type inference, interface matching, and class method parity.
  • Accepted and verified updated baselines for the new test and affected existing tests (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.

Copilot AI balanced review requested due to automatic review settings November 8, 2026 09:33
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 8, 2026
@typescript-automation typescript-automation Bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Nov 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

[DTS] Object literal method with bigint is omitted in generated .d.ts, but class method works correctly

3 participants