From fd56f7a52ae145f14e327d07b05ec7e22c8bee54 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Wed, 29 Jul 2026 22:39:32 +0800 Subject: [PATCH] Cleanup failed tests (#19749) --- .../config/format-test/failed-format-tests.js | 38 ++------------- .../__snapshots__/format.test.js.snap | 22 +++++++++ .../format/typescript/compiler/format.test.js | 4 +- .../__snapshots__/format.test.js.snap | 46 +++++++++++++++++++ .../importDeclarations/format.test.js | 11 ++++- .../ambient/__snapshots__/format.test.js.snap | 12 +++++ .../conformance/types/ambient/format.test.js | 4 +- .../__snapshots__/format.test.js.snap | 10 ++++ .../types/moduleDeclaration/format.test.js | 4 +- .../const/__snapshots__/format.test.js.snap | 10 ++++ tests/format/typescript/const/format.test.js | 4 +- .../__snapshots__/format.test.js.snap | 12 ++++- .../custom/stability/format.test.js | 4 +- .../{moduleBlock.ts => module-block.ts} | 0 .../__snapshots__/format.test.js.snap | 10 ++++ .../typescript/interface2/format.test.js | 2 +- .../__snapshots__/format.test.js.snap | 20 ++++++++ .../format/typescript/keywords/format.test.js | 4 +- .../module/__snapshots__/format.test.js.snap | 37 +++++++++++++-- tests/format/typescript/module/format.test.js | 4 +- .../{module_nested.ts => module-nested.ts} | 0 ...pace_function.ts => namespace-function.ts} | 0 ...amespace_nested.ts => namespace-nested.ts} | 0 23 files changed, 210 insertions(+), 48 deletions(-) rename tests/format/typescript/custom/stability/{moduleBlock.ts => module-block.ts} (100%) rename tests/format/typescript/module/{module_nested.ts => module-nested.ts} (100%) rename tests/format/typescript/module/{namespace_function.ts => namespace-function.ts} (100%) rename tests/format/typescript/module/{namespace_nested.ts => namespace-nested.ts} (100%) diff --git a/tests/config/format-test/failed-format-tests.js b/tests/config/format-test/failed-format-tests.js index 3dcb2737c..7d16fd5c2 100644 --- a/tests/config/format-test/failed-format-tests.js +++ b/tests/config/format-test/failed-format-tests.js @@ -51,48 +51,16 @@ const commentClosureTypecaseTests = [ const disabledTests = new Map( Object.entries({ - espree: [ - ...commentClosureTypecaseTests, - "js/explicit-resource-management/valid-await-using-asi-assignment.js", - ], - acorn: [ - "js/explicit-resource-management/valid-await-using-asi-assignment.js", - ], + espree: commentClosureTypecaseTests, + acorn: [], meriyah: [], - "babel-ts": [ - "typescript/conformance/types/moduleDeclaration/kind-detection.ts", - // https://github.com/babel/babel/pull/17659 - "typescript/conformance/internalModules/importDeclarations/circularImportAlias.ts", - "typescript/conformance/internalModules/importDeclarations/exportImportAlias.ts", - "typescript/conformance/internalModules/importDeclarations/importAliasIdentifiers.ts", - "typescript/conformance/internalModules/importDeclarations/shadowedInternalModule.ts", - "typescript/conformance/types/moduleDeclaration/moduleDeclaration.ts", - "typescript/conformance/types/ambient/ambientDeclarations.ts", - "typescript/compiler/declareDottedModuleName.ts", - "typescript/compiler/privacyGloImport.ts", - "typescript/declare/declare_module.ts", - "typescript/const/initializer-ambient-context.ts", - "typescript/keywords/keywords.ts", - "typescript/keywords/module.ts", - "typescript/module/global.ts", - "typescript/module/keyword.ts", - "typescript/module/module_nested.ts", - "typescript/custom/stability/moduleBlock.ts", - "typescript/interface2/module.ts", - ], + "babel-ts": [], oxc: [], "oxc-ts": [], yuku: ["js/await/await-with-parens.js"], "yuku-ts": ["js/await/await-with-parens.js"], hermes: [ - ...commentClosureTypecaseTests, - - // Not supported - "flow/comments/", - "flow/flow-repo/union_new/", - // Different result - "flow/hook/comments-before-arrow.js", "js/await/like-call.js", ], flow: [ diff --git a/tests/format/typescript/compiler/__snapshots__/format.test.js.snap b/tests/format/typescript/compiler/__snapshots__/format.test.js.snap index afd70c380..f41a08ec1 100644 --- a/tests/format/typescript/compiler/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/compiler/__snapshots__/format.test.js.snap @@ -315,6 +315,17 @@ module T.U { ================================================================================ `; +exports[`declareDottedModuleName.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (2:1) + 1 | // @declaration: true +> 2 | module M { + | ^ + 3 | module P.Q { } // This shouldnt be emitted + 4 | } + 5 | +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (2:0)" +`; + exports[`decrementAndIncrementOperators.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -870,3 +881,14 @@ module m2 { ================================================================================ `; + +exports[`privacyGloImport.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (2:1) + 1 | //@declaration: true +> 2 | module m1 { + | ^ + 3 | export module m1_M1_public { + 4 | export class c1 { + 5 | } +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (2:0)" +`; diff --git a/tests/format/typescript/compiler/format.test.js b/tests/format/typescript/compiler/format.test.js index 116dcbd78..13895d3bd 100644 --- a/tests/format/typescript/compiler/format.test.js +++ b/tests/format/typescript/compiler/format.test.js @@ -1 +1,3 @@ -runFormatTest(import.meta, ["typescript"]); +runFormatTest(import.meta, ["typescript"], { + errors: { "babel-ts": ["declareDottedModuleName.ts", "privacyGloImport.ts"] }, +}); diff --git a/tests/format/typescript/conformance/internalModules/importDeclarations/__snapshots__/format.test.js.snap b/tests/format/typescript/conformance/internalModules/importDeclarations/__snapshots__/format.test.js.snap index 28509014a..0d53102d9 100644 --- a/tests/format/typescript/conformance/internalModules/importDeclarations/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/conformance/internalModules/importDeclarations/__snapshots__/format.test.js.snap @@ -47,6 +47,18 @@ var c = new B.a.C(); ================================================================================ `; +exports[`circularImportAlias.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (3:1) + 1 | // expected no error + 2 | +> 3 | module B { + | ^ + 4 | export import a = A; + 5 | export class D extends a.C { + 6 | id: number; +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (3:0)" +`; + exports[`exportImportAlias.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -197,6 +209,18 @@ var p: M.D.Point; ================================================================================ `; +exports[`exportImportAlias.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (3:1) + 1 | // expect no errors here + 2 | +> 3 | module A { + | ^ + 4 | + 5 | export var x = 'hello world' + 6 | export class Point { +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (3:0)" +`; + exports[`exportInterface.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -315,6 +339,16 @@ var p: { x: number; y: number }; ================================================================================ `; +exports[`importAliasIdentifiers.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:1) +> 1 | module moduleA { + | ^ + 2 | export class Point { + 3 | constructor(public x: number, public y: number) { } + 4 | } +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:0)" +`; + exports[`invalidImportAliasIdentifiers.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -448,3 +482,15 @@ module Z { ================================================================================ `; + +exports[`shadowedInternalModule.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (3:1) + 1 | // all errors imported modules conflict with local variables + 2 | +> 3 | module A { + | ^ + 4 | export var Point = { x: 0, y: 0 } + 5 | export interface Point { + 6 | x: number; +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (3:0)" +`; diff --git a/tests/format/typescript/conformance/internalModules/importDeclarations/format.test.js b/tests/format/typescript/conformance/internalModules/importDeclarations/format.test.js index 116dcbd78..d11bfa99a 100644 --- a/tests/format/typescript/conformance/internalModules/importDeclarations/format.test.js +++ b/tests/format/typescript/conformance/internalModules/importDeclarations/format.test.js @@ -1 +1,10 @@ -runFormatTest(import.meta, ["typescript"]); +runFormatTest(import.meta, ["typescript"], { + errors: { + "babel-ts": [ + "circularImportAlias.ts", + "exportImportAlias.ts", + "importAliasIdentifiers.ts", + "shadowedInternalModule.ts", + ], + }, +}); diff --git a/tests/format/typescript/conformance/types/ambient/__snapshots__/format.test.js.snap b/tests/format/typescript/conformance/types/ambient/__snapshots__/format.test.js.snap index ff9c34a8a..49caa5741 100644 --- a/tests/format/typescript/conformance/types/ambient/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/conformance/types/ambient/__snapshots__/format.test.js.snap @@ -30,3 +30,15 @@ declare namespace f {} ================================================================================ `; + +exports[`ambientDeclarations.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (8:16) + 6 | declare interface c {} + 7 | declare class d {} +> 8 | declare module e {} + | ^ + 9 | declare module "g" {} + 10 | declare namespace f {} + 11 | +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (8:15)" +`; diff --git a/tests/format/typescript/conformance/types/ambient/format.test.js b/tests/format/typescript/conformance/types/ambient/format.test.js index 116dcbd78..93a1a3c76 100644 --- a/tests/format/typescript/conformance/types/ambient/format.test.js +++ b/tests/format/typescript/conformance/types/ambient/format.test.js @@ -1 +1,3 @@ -runFormatTest(import.meta, ["typescript"]); +runFormatTest(import.meta, ["typescript"], { + errors: { "babel-ts": ["ambientDeclarations.ts"] }, +}); diff --git a/tests/format/typescript/conformance/types/moduleDeclaration/__snapshots__/format.test.js.snap b/tests/format/typescript/conformance/types/moduleDeclaration/__snapshots__/format.test.js.snap index 547270190..710a5b3c5 100644 --- a/tests/format/typescript/conformance/types/moduleDeclaration/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/conformance/types/moduleDeclaration/__snapshots__/format.test.js.snap @@ -39,3 +39,13 @@ declare module "B" { ================================================================================ `; + +exports[`moduleDeclaration.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:1) +> 1 | module A { + | ^ + 2 | export class A { + 3 | } + 4 | } +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:0)" +`; diff --git a/tests/format/typescript/conformance/types/moduleDeclaration/format.test.js b/tests/format/typescript/conformance/types/moduleDeclaration/format.test.js index 116dcbd78..5d77328fe 100644 --- a/tests/format/typescript/conformance/types/moduleDeclaration/format.test.js +++ b/tests/format/typescript/conformance/types/moduleDeclaration/format.test.js @@ -1 +1,3 @@ -runFormatTest(import.meta, ["typescript"]); +runFormatTest(import.meta, ["typescript"], { + errors: { "babel-ts": ["moduleDeclaration.ts"] }, +}); diff --git a/tests/format/typescript/const/__snapshots__/format.test.js.snap b/tests/format/typescript/const/__snapshots__/format.test.js.snap index 510090b05..474cf351d 100644 --- a/tests/format/typescript/const/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/const/__snapshots__/format.test.js.snap @@ -40,3 +40,13 @@ declare module N { ================================================================================ `; + +exports[`initializer-ambient-context.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:16) +> 1 | declare module N { + | ^ + 2 | enum E { + 3 | ok = 0 + 4 | } +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:15)" +`; diff --git a/tests/format/typescript/const/format.test.js b/tests/format/typescript/const/format.test.js index 116dcbd78..c0a7258c9 100644 --- a/tests/format/typescript/const/format.test.js +++ b/tests/format/typescript/const/format.test.js @@ -1 +1,3 @@ -runFormatTest(import.meta, ["typescript"]); +runFormatTest(import.meta, ["typescript"], { + errors: { "babel-ts": ["initializer-ambient-context.ts"] }, +}); diff --git a/tests/format/typescript/custom/stability/__snapshots__/format.test.js.snap b/tests/format/typescript/custom/stability/__snapshots__/format.test.js.snap index de733425b..729a7c255 100644 --- a/tests/format/typescript/custom/stability/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/custom/stability/__snapshots__/format.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing -exports[`moduleBlock.ts format 1`] = ` +exports[`module-block.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 (default) | @@ -53,3 +53,13 @@ module m2 { ================================================================================ `; + +exports[`module-block.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:1) +> 1 | module m2 { + | ^ + 2 | function fn() { + 3 | return 1; + 4 | } +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:0)" +`; diff --git a/tests/format/typescript/custom/stability/format.test.js b/tests/format/typescript/custom/stability/format.test.js index 116dcbd78..7bcb4dbf6 100644 --- a/tests/format/typescript/custom/stability/format.test.js +++ b/tests/format/typescript/custom/stability/format.test.js @@ -1 +1,3 @@ -runFormatTest(import.meta, ["typescript"]); +runFormatTest(import.meta, ["typescript"], { + errors: { "babel-ts": ["module-block.ts"] }, +}); diff --git a/tests/format/typescript/custom/stability/moduleBlock.ts b/tests/format/typescript/custom/stability/module-block.ts similarity index 100% rename from tests/format/typescript/custom/stability/moduleBlock.ts rename to tests/format/typescript/custom/stability/module-block.ts diff --git a/tests/format/typescript/interface2/__snapshots__/format.test.js.snap b/tests/format/typescript/interface2/__snapshots__/format.test.js.snap index c48369f97..3840ed237 100644 --- a/tests/format/typescript/interface2/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/interface2/__snapshots__/format.test.js.snap @@ -118,6 +118,16 @@ declare module X { ================================================================================ `; +exports[`module.ts - {"trailingComma":"es5"} format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:16) +> 1 | declare module X { + | ^ + 2 | declare interface Y { x: number; } + 3 | } + 4 | +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:15)" +`; + exports[`module.ts - {"trailingComma":"es5"} format[oxc-ts] 1`] = ` "A 'declare' modifier cannot be used in an already ambient context. (2:3) 1 | declare module X { diff --git a/tests/format/typescript/interface2/format.test.js b/tests/format/typescript/interface2/format.test.js index a877b1bba..9e66b862d 100644 --- a/tests/format/typescript/interface2/format.test.js +++ b/tests/format/typescript/interface2/format.test.js @@ -1,4 +1,4 @@ runFormatTest(import.meta, ["typescript", "flow"], { trailingComma: "es5", - errors: { "oxc-ts": ["module.ts"] }, + errors: { "oxc-ts": ["module.ts"], "babel-ts": ["module.ts"] }, }); diff --git a/tests/format/typescript/keywords/__snapshots__/format.test.js.snap b/tests/format/typescript/keywords/__snapshots__/format.test.js.snap index b5a461be5..d47de8e3b 100644 --- a/tests/format/typescript/keywords/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/keywords/__snapshots__/format.test.js.snap @@ -70,6 +70,16 @@ module YYY4 { ================================================================================ `; +exports[`keywords.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:1) +> 1 | module Y4 { + | ^ + 2 | enum Color { Blue, Red } + 3 | } + 4 | +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:0)" +`; + exports[`keywords-2.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -170,3 +180,13 @@ module Y3 { ================================================================================ `; + +exports[`module.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:1) +> 1 | module Y3 { + | ^ + 2 | module Module { + 3 | class A { s: string } + 4 | } +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:0)" +`; diff --git a/tests/format/typescript/keywords/format.test.js b/tests/format/typescript/keywords/format.test.js index 116dcbd78..21f343027 100644 --- a/tests/format/typescript/keywords/format.test.js +++ b/tests/format/typescript/keywords/format.test.js @@ -1 +1,3 @@ -runFormatTest(import.meta, ["typescript"]); +runFormatTest(import.meta, ["typescript"], { + errors: { "babel-ts": ["keywords.ts", "module.ts"] }, +}); diff --git a/tests/format/typescript/module/__snapshots__/format.test.js.snap b/tests/format/typescript/module/__snapshots__/format.test.js.snap index 4e9f7c587..32dcebc5c 100644 --- a/tests/format/typescript/module/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/module/__snapshots__/format.test.js.snap @@ -40,6 +40,17 @@ declare namespace global {} ================================================================================ `; +exports[`global.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (2:1) + 1 | namespace global {} +> 2 | module global {} + | ^ + 3 | global {} + 4 | declare global {} + 5 | declare /* module */ global {} +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (2:0)" +`; + exports[`keyword.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -121,7 +132,17 @@ module /* namespace */ "x" {} ================================================================================ `; -exports[`module_nested.ts format 1`] = ` +exports[`keyword.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:1) +> 1 | module X {} + | ^ + 2 | + 3 | module X { + 4 | const x = 1; +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:0)" +`; + +exports[`module-nested.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 (default) | @@ -162,7 +183,17 @@ module abc4.def.ghi {} ================================================================================ `; -exports[`namespace_function.ts format 1`] = ` +exports[`module-nested.ts format[babel-ts] 1`] = ` +"\`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:16) +> 1 | declare module abc1.def {} + | ^ + 2 | + 3 | export declare module abc2.def {} + 4 | +Cause: \`module ... {}\` declarations must have a string name. Use \`namespace ... {}\` instead. (1:15)" +`; + +exports[`namespace-function.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 (default) | @@ -179,7 +210,7 @@ namespace X { ================================================================================ `; -exports[`namespace_nested.ts format 1`] = ` +exports[`namespace-nested.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 (default) | diff --git a/tests/format/typescript/module/format.test.js b/tests/format/typescript/module/format.test.js index 116dcbd78..6c2be929d 100644 --- a/tests/format/typescript/module/format.test.js +++ b/tests/format/typescript/module/format.test.js @@ -1 +1,3 @@ -runFormatTest(import.meta, ["typescript"]); +runFormatTest(import.meta, ["typescript"], { + errors: { "babel-ts": ["global.ts", "keyword.ts", "module-nested.ts"] }, +}); diff --git a/tests/format/typescript/module/module_nested.ts b/tests/format/typescript/module/module-nested.ts similarity index 100% rename from tests/format/typescript/module/module_nested.ts rename to tests/format/typescript/module/module-nested.ts diff --git a/tests/format/typescript/module/namespace_function.ts b/tests/format/typescript/module/namespace-function.ts similarity index 100% rename from tests/format/typescript/module/namespace_function.ts rename to tests/format/typescript/module/namespace-function.ts diff --git a/tests/format/typescript/module/namespace_nested.ts b/tests/format/typescript/module/namespace-nested.ts similarity index 100% rename from tests/format/typescript/module/namespace_nested.ts rename to tests/format/typescript/module/namespace-nested.ts