microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.08k stars 12.37k forks source link

Debug Failure in transformClassLike in "ghost" after #56955 #58269

Open jakebailey opened 4 months ago

jakebailey commented 4 months ago

🔎 Search Terms

Error Debug Failure at transformClassLike

🕗 Version & Regression Information

⏯ Playground Link

No response

💻 Code

$ git clone git@github.com:TryGhost/Ghost.git
$ cd Ghost
$ git rev-parse HEAD
69372d9018f156d56ae271b6d8e378efb9ea3012
$ yarn
$ node --enable-source-maps ~/work/TypeScript/built/local/tsc.js -p ghost/tsconfig.json

🙁 Actual behavior

/home/jabaile/work/TypeScript/src/compiler/program.ts:2918
            throw e;
            ^

Error: Debug Failure.
    at transformClassLike (/home/jabaile/work/TypeScript/src/compiler/transformers/esDecorators.ts:700:19)
    at visitClassDeclaration (/home/jabaile/work/TypeScript/src/compiler/transformers/esDecorators.ts:1094:30)
    at visitor (/home/jabaile/work/TypeScript/src/compiler/transformers/esDecorators.ts:432:24)
    at visitArrayWorker (/home/jabaile/work/TypeScript/src/compiler/visitorPublic.ts:345:57)
    at visitNodes2 (/home/jabaile/work/TypeScript/src/compiler/visitorPublic.ts:258:21)
    at visitLexicalEnvironment (/home/jabaile/work/TypeScript/src/compiler/visitorPublic.ts:383:18)
    at visitEachChildOfSourceFile (/home/jabaile/work/TypeScript/src/compiler/visitorPublic.ts:1779:13)
    at visitEachChild (/home/jabaile/work/TypeScript/src/compiler/visitorPublic.ts:603:38)
    at transformSourceFile (/home/jabaile/work/TypeScript/src/compiler/transformers/esDecorators.ts:317:25)
    at transformSourceFileOrBundle (/home/jabaile/work/TypeScript/src/compiler/transformers/utilities.ts:130:54)

Node.js v20.12.2

🙂 Expected behavior

No crash.

Additional information about the issue

This bisects to #56955, at:

Debug.assertIsDefined(classInfo.classThis);
jakebailey commented 4 months ago

Source file is ghost/ghost/src/listeners/example.listener.ts, node is:

export class ExampleListener {
    constructor(
        @Inject('logger') private logger: Logger
    ) {}

    @OnEvent(ExampleEvent)
    async logEvents(event: ExampleEvent) {
        this.logger.info(`Received an event with a message: ${event.data.message}`);
    }
}

Which does crash the playground when I put it there.