TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Deprecate `module` syntax

Open RyanCavanaugh opened this issue 2 weeks ago • 13 comments

See #54500 Fixes #62211

This changes the existing suggestion diagnostic to an error when you write forms like module foo or module foo.bar {

~The ambient form declare module foo { is still ok~ edit: no, we agreed in #62211 to also deprecate that form, as is the ambient module declaration form declare module "specifier" {

RyanCavanaugh avatar Dec 10 '25 21:12 RyanCavanaugh

@typescript-bot test top800

RyanCavanaugh avatar Dec 10 '25 22:12 RyanCavanaugh

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top800 ✅ Started ✅ Results

typescript-bot avatar Dec 10 '25 22:12 typescript-bot

@RyanCavanaugh Here are the results of running the top 800 repos with tsc comparing main and refs/pull/62876/merge:

Everything looks good!

typescript-bot avatar Dec 11 '25 00:12 typescript-bot

@typescript-bot pack this

DanielRosenwasser avatar Dec 11 '25 08:12 DanielRosenwasser

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

typescript-bot avatar Dec 11 '25 08:12 typescript-bot

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/166787/artifacts?artifactName=tgz&fileId=5B5A1DC78D2CF32FC54B5EBC8ACD09579FF86E294083153584D973D89884D14D02&fileName=/typescript-6.0.0-insiders.20251211.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

typescript-bot avatar Dec 11 '25 08:12 typescript-bot

Thanks for the pack. A quick try out suggest that when you provoke the intended checker error, it crashes.

Error: Debug Failure. Should never get an Info diagnostic on the command line.
    at getCategoryFormat (/home/projects/stackblitz-starters-ybxu3fvk/node_modules/typescript/lib/_tsc.js:121656:20)
    at formatDiagnosticsWithColorAndContext (/home/projects/stackblitz-starters-ybxu3fvk/node_modules/typescript/lib/_tsc.js:121721:71)

robpalme avatar Dec 11 '25 09:12 robpalme

A quick try out suggest that when you provoke the intended checker error, it crashes.

Well, that's one way to get people to change their code 🤦

RyanCavanaugh avatar Dec 11 '25 16:12 RyanCavanaugh

@typescript-bot test top800 @typescript-bot pack this

RyanCavanaugh avatar Dec 11 '25 17:12 RyanCavanaugh

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top800 ✅ Started 👀 Results
pack this ✅ Started ✅ Results

typescript-bot avatar Dec 11 '25 17:12 typescript-bot

Hey @RyanCavanaugh, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/166789/artifacts?artifactName=tgz&fileId=F7B95EBDF36B0403901B7D4CB436D9FE693D2E5245B7A658F1362E103A40D18402&fileName=/typescript-6.0.0-insiders.20251211.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

typescript-bot avatar Dec 11 '25 17:12 typescript-bot

The new pack works great. No crashes!

And it correctly errors on the declare form. Thank you for that update 💙

The only issue I observe is that for all forms, the error squiggles are on the identifier, not the keyword. Which seems a bit misleading.

index.ts:3:16 - error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead.

3 declare module types {
                 ~~~~~


Found 1 error in index.ts:3

robpalme avatar Dec 11 '25 18:12 robpalme

@RyanCavanaugh Here are the results of running the top 800 repos with tsc comparing main and refs/pull/62876/merge:

Something interesting changed - please have a look.

Details

microsoft/vscode

11 of 63 projects failed to build with the old tsc and were ignored

src/tsconfig.tsec.json

src/tsconfig.monaco.json

build/checker/tsconfig.worker.json

build/checker/tsconfig.electron-utility.json

build/checker/tsconfig.electron-main.json

build/checker/tsconfig.electron-browser.json

typescript-bot avatar Dec 11 '25 19:12 typescript-bot

@typescript-bot test top800

jakebailey avatar Dec 11 '25 21:12 jakebailey

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top800 ✅ Started ✅ Results

typescript-bot avatar Dec 11 '25 21:12 typescript-bot

@jakebailey Here are the results of running the top 800 repos with tsc comparing main and refs/pull/62876/merge:

Everything looks good!

typescript-bot avatar Dec 11 '25 23:12 typescript-bot