diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index 2f2d23c468089..40662f302269c 100644 --- a/src/compiler/transformers/module/esnextAnd2015.ts +++ b/src/compiler/transformers/module/esnextAnd2015.ts @@ -158,7 +158,7 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S if (node === importsAndRequiresToRewriteOrShim?.[0]) { return visitImportOrRequireCall(importsAndRequiresToRewriteOrShim.shift()!); } - break; + // fallthrough default: if (importsAndRequiresToRewriteOrShim?.length && rangeContainsRange(node, importsAndRequiresToRewriteOrShim[0])) { return visitEachChild(node, visitor, context); diff --git a/tests/baselines/reference/emit(jsx=preserve).errors.txt b/tests/baselines/reference/emit(jsx=preserve).errors.txt index cda66163154d1..894ae70f4392d 100644 --- a/tests/baselines/reference/emit(jsx=preserve).errors.txt +++ b/tests/baselines/reference/emit(jsx=preserve).errors.txt @@ -6,6 +6,8 @@ main.ts(6,22): error TS2307: Cannot find module './foo.ts' or its corresponding main.ts(8,15): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. main.ts(10,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. main.ts(11,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. +main.ts(13,18): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. +main.ts(14,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. no.ts(1,16): error TS2307: Cannot find module './foo.ts/foo.js' or its corresponding type declarations. no.ts(2,16): error TS2307: Cannot find module 'foo.ts' or its corresponding type declarations. no.ts(3,16): error TS2307: Cannot find module 'pkg/foo.ts' or its corresponding type declarations. @@ -21,7 +23,7 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t ==== globals.d.ts (0 errors) ==== declare function require(module: string): any; -==== main.ts (8 errors) ==== +==== main.ts (10 errors) ==== // Rewrite import {} from "./foo.ts"; ~~~~~~~~~~ @@ -45,6 +47,13 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t //Shim import("./foo.ts"); ~~~~~~~~~~ +!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. + import("./foo.ts").then(() => {}); + ~~~~~~~~~~ +!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. + function acceptAny(arg: any) {} + acceptAny(import("./foo.ts")); + ~~~~~~~~~~ !!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. import("./foo.ts", { with: { attr: "value" } }); ~~~~~~~~~~ diff --git a/tests/baselines/reference/emit(jsx=preserve).js b/tests/baselines/reference/emit(jsx=preserve).js index 101590ab644b9..46da467f6ac0b 100644 --- a/tests/baselines/reference/emit(jsx=preserve).js +++ b/tests/baselines/reference/emit(jsx=preserve).js @@ -14,6 +14,9 @@ import "./foo.ts"; export * from "./foo.ts"; //Shim import("./foo.ts"); +import("./foo.ts").then(() => {}); +function acceptAny(arg: any) {} +acceptAny(import("./foo.ts")); import("./foo.ts", { with: { attr: "value" } }); import("" + "./foo.ts"); //// [js.js] @@ -71,6 +74,9 @@ import "./foo.js"; export * from "./foo.js"; //Shim import("./foo.js"); +import("./foo.js").then(() => { }); +function acceptAny(arg) { } +acceptAny(import("./foo.js")); import("./foo.js", { with: { attr: "value" } }); import(__rewriteRelativeImportExtension("" + "./foo.ts", true)); //// [js.js] diff --git a/tests/baselines/reference/emit(jsx=react).errors.txt b/tests/baselines/reference/emit(jsx=react).errors.txt index cda66163154d1..894ae70f4392d 100644 --- a/tests/baselines/reference/emit(jsx=react).errors.txt +++ b/tests/baselines/reference/emit(jsx=react).errors.txt @@ -6,6 +6,8 @@ main.ts(6,22): error TS2307: Cannot find module './foo.ts' or its corresponding main.ts(8,15): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. main.ts(10,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. main.ts(11,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. +main.ts(13,18): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. +main.ts(14,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. no.ts(1,16): error TS2307: Cannot find module './foo.ts/foo.js' or its corresponding type declarations. no.ts(2,16): error TS2307: Cannot find module 'foo.ts' or its corresponding type declarations. no.ts(3,16): error TS2307: Cannot find module 'pkg/foo.ts' or its corresponding type declarations. @@ -21,7 +23,7 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t ==== globals.d.ts (0 errors) ==== declare function require(module: string): any; -==== main.ts (8 errors) ==== +==== main.ts (10 errors) ==== // Rewrite import {} from "./foo.ts"; ~~~~~~~~~~ @@ -45,6 +47,13 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t //Shim import("./foo.ts"); ~~~~~~~~~~ +!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. + import("./foo.ts").then(() => {}); + ~~~~~~~~~~ +!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. + function acceptAny(arg: any) {} + acceptAny(import("./foo.ts")); + ~~~~~~~~~~ !!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations. import("./foo.ts", { with: { attr: "value" } }); ~~~~~~~~~~ diff --git a/tests/baselines/reference/emit(jsx=react).js b/tests/baselines/reference/emit(jsx=react).js index e25e6fd2f058d..a3074c3e2fb8e 100644 --- a/tests/baselines/reference/emit(jsx=react).js +++ b/tests/baselines/reference/emit(jsx=react).js @@ -14,6 +14,9 @@ import "./foo.ts"; export * from "./foo.ts"; //Shim import("./foo.ts"); +import("./foo.ts").then(() => {}); +function acceptAny(arg: any) {} +acceptAny(import("./foo.ts")); import("./foo.ts", { with: { attr: "value" } }); import("" + "./foo.ts"); //// [js.js] @@ -71,6 +74,9 @@ import "./foo.js"; export * from "./foo.js"; //Shim import("./foo.js"); +import("./foo.js").then(() => { }); +function acceptAny(arg) { } +acceptAny(import("./foo.js")); import("./foo.js", { with: { attr: "value" } }); import(__rewriteRelativeImportExtension("" + "./foo.ts")); //// [js.js] diff --git a/tests/cases/conformance/externalModules/rewriteRelativeImportExtensions/emit.ts b/tests/cases/conformance/externalModules/rewriteRelativeImportExtensions/emit.ts index 57af4ea118719..4636edf650d36 100644 --- a/tests/cases/conformance/externalModules/rewriteRelativeImportExtensions/emit.ts +++ b/tests/cases/conformance/externalModules/rewriteRelativeImportExtensions/emit.ts @@ -21,6 +21,9 @@ import "./foo.ts"; export * from "./foo.ts"; //Shim import("./foo.ts"); +import("./foo.ts").then(() => {}); +function acceptAny(arg: any) {} +acceptAny(import("./foo.ts")); import("./foo.ts", { with: { attr: "value" } }); import("" + "./foo.ts"); // @Filename: js.js