Skip to content

Declaration emit crashes on an imported class indexed by a computed unique-symbol static #65744

Backlog

Description

🔎 Search Terms

declaration emit crash unique symbol computed static, emitIdentifierText, "Debug failure. False expression", typeof key indexed access

🕗 Version & Regression Information

  • This changed between versions 6.0 and 7.0: TypeScript 6.0.3 doesn't crash, but it emits typeof key without importing key (see below). The Go port crashes.

⏯ Playground Link

No response

💻 Code

// @declaration: true

// @Filename: statics.ts
export declare const key: unique symbol;
export declare class K {
    static readonly [key]: unique symbol;
}

// @Filename: main.ts
import { K, key } from "./statics";
export const obj = { k: K[key] } as const;

🙁 Actual behavior

tsc -p . (with declaration: true) panics while emitting main.d.ts:

panic: Debug failure. False expression.

github.com/microsoft/TypeScript/tsc/internal/printer.(*Printer).emitIdentifierText
github.com/microsoft/TypeScript/tsc/internal/printer.(*Printer).emitIdentifierReference
github.com/microsoft/TypeScript/tsc/internal/printer.(*Printer).emitEntityName
github.com/microsoft/TypeScript/tsc/internal/printer.(*Printer).emitTypeQuery
github.com/microsoft/TypeScript/tsc/internal/printer.(*Printer).emitIndexedAccessType
...

The type of obj.k is serialized as (typeof K)[typeof key]. When the node builder handles a computed property name in createAccessFromSymbolChain, it puts the declaration's own key expression from statics.ts into the type query. It doesn't create a new reference to key. The printer then asserts because that identifier belongs to a different source file than the one being emitted.

TypeScript 6.0.3 emits this instead:

import { K } from "./statics";
export declare const obj: {
    readonly k: (typeof K)[typeof key];
};

Here key is never imported, so the generated declaration file doesn't resolve.

🙂 Expected behavior

No crash, and a declaration file that resolves on its own. For example:

import { K, key } from "./statics";
export declare const obj: {
    readonly k: (typeof K)[typeof key];
};

Additional information about the issue

The type uses the computed-name path in createAccessFromSymbolChain (tsc/internal/checker/nodebuilderimpl.go). Any other caller that reaches a computed static unique-symbol member through another file will probably hit the same crash. It happens with plain identifier exports, so it isn't tied to string export names.

Found while reviewing #65665.

Activity

  1. added
    Crash
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Crash

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions