Decorator declaration inside a function causes the typescript language server to crash
Closed this issue ยท 3 comments
๐ Search Terms
decorator language server crash
๐ Version & Regression Information
- This is the behavior in every version I tried (5.9.3 and 5.4.5), and I reviewed the FAQ for entries about "decorator"
โฏ Playground Link
๐ป Code
import { Page, test } from "@playwright/test";
export function step(target: (...args: any[]) => any, context: ClassMethodDecoratorContext) {
return function replacementMethod(...args: any) {
const name = this.constructor.name + "." + (context.name as string) + "(" + (args as string) + ")";
return test.step(name, async () => {
return await target.call(this, ...args);
});
};
}
class SomeClass {
constructor(public readonly p: Page) {}
@step
async gotoSomePage(url: string) {
@step
await this.p.goto(url);
}
}๐ Actual behavior
when (by accident) a decorator method was added into a function (line 17 / line 15 in the TS Playground), the typescript language server just gives up and exits with SIGTERM.
๐ Expected behavior
mark the second decorator as wrong, or at least have the language-server exit SIGTERM with a more meaningful explanation into the Logfiles. Have it print out, in which location the language server failed. tsc just print "Error: Debug Failure. False expression."
In my Repo, I had 10 files changed and I was looking for 4 hours to find the issue.
Additional information about the issue
I uploaded this to a repository here: https://github.com/devilofhell/decorator-crashes-ts-language-service/blob/main/page.ts
Here is a picture of the VS Code log:

Note: this only happens after you start VS Code, or open a new file, since only that triggers the language server to build up its content. VS Code just gives up after 5 retries.
here is the log file from /home/r975115/.vscode-server/data/logs/20251022T110530/exthost7/vscode.typescript-language-features/tsserver-log-cYXMY8/tsserver.log
if executing tsc, it says nothing meaningful. no information why or where it crashed.
/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:1284
throw e;
^
Error: Debug Failure. False expression.
at parseVariableDeclarationList (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33762:15)
at parseVariableStatement (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33788:29)
at parseDeclarationWorker (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33602:16)
at parseDeclaration (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33584:14)
at parseStatement (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33537:16)
at parseListElement (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:30115:12)
at parseList (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:30100:19)
at parseBlock (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:32993:26)
at parseFunctionBlock (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33024:19)
at parseFunctionBlockOrSemicolon (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33667:12)the barebones repro is just this:
@dec
await 1This is fixed in TS7.
a.ts:1:1 - error TS1206: Decorators are not valid here.
1 @dec
~
Given how unlikely this mistake is, I don't think this warrants trying to fix in the 5.9/6 codebase, so we'll call this "fixed in a future release"
Never mind, that linked fix is obviously correct