From e1629e540ef361167e0c96c8703728a419b6e8e9 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 10 Feb 2025 09:26:52 -0800 Subject: [PATCH 1/3] Pass ignoreErrors=true to more resolveEntityName callers (#61144) --- src/compiler/checker.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 090f8dcd50e..d9d1950d6b6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -49148,11 +49148,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } else if (isEntityName(name) && isTypeReferenceIdentifier(name)) { const meaning = name.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace; - const symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + const symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ true, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } if (name.parent.kind === SyntaxKind.TypePredicate) { - return resolveEntityName(name as Identifier, /*meaning*/ SymbolFlags.FunctionScopedVariable); + return resolveEntityName(name as Identifier, /*meaning*/ SymbolFlags.FunctionScopedVariable, /*ignoreErrors*/ true); } return undefined; } @@ -49383,7 +49383,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getShorthandAssignmentValueSymbol(location: Node | undefined): Symbol | undefined { if (location && location.kind === SyntaxKind.ShorthandPropertyAssignment) { - return resolveEntityName((location as ShorthandPropertyAssignment).name, SymbolFlags.Value | SymbolFlags.Alias); + return resolveEntityName((location as ShorthandPropertyAssignment).name, SymbolFlags.Value | SymbolFlags.Alias, /*ignoreErrors*/ true); } return undefined; } @@ -49395,10 +49395,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : name.kind === SyntaxKind.StringLiteral ? undefined : // Skip for invalid syntax like this: export { "x" } - resolveEntityName(name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + resolveEntityName(name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*ignoreErrors*/ true); } else { - return resolveEntityName(node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + return resolveEntityName(node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*ignoreErrors*/ true); } } From 775412a81af187e67371cd31719d19ab075b4ef3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 09:27:08 -0800 Subject: [PATCH 2/3] Bump github/codeql-action from 3.28.8 to 3.28.9 in the github-actions group (#61156) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/scorecard.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7a4c1ba8663..d0d0ebc1a44 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -46,7 +46,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8 + uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9 with: config-file: ./.github/codeql/codeql-configuration.yml # Override language selection by uncommenting this and choosing your languages @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below). - name: Autobuild - uses: github/codeql-action/autobuild@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8 + uses: github/codeql-action/autobuild@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -70,4 +70,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8 + uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 389790241e4..cca13091e26 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -55,6 +55,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: 'Upload to code-scanning' - uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8 + uses: github/codeql-action/upload-sarif@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9 with: sarif_file: results.sarif From df342b7206cb56b56bb3b3aecbb2ee2d2ff7b217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 11 Feb 2025 00:02:37 +0100 Subject: [PATCH 3/3] Fixed `rewriteRelativeImportExtensions` for `import()` within call expressions (#61154) --- src/compiler/transformers/module/esnextAnd2015.ts | 2 +- .../baselines/reference/emit(jsx=preserve).errors.txt | 11 ++++++++++- tests/baselines/reference/emit(jsx=preserve).js | 6 ++++++ tests/baselines/reference/emit(jsx=react).errors.txt | 11 ++++++++++- tests/baselines/reference/emit(jsx=react).js | 6 ++++++ .../rewriteRelativeImportExtensions/emit.ts | 3 +++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index 2f2d23c4680..40662f30226 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 cda66163154..894ae70f439 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 101590ab644..46da467f6ac 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 cda66163154..894ae70f439 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 e25e6fd2f05..a3074c3e2fb 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 57af4ea1187..4636edf650d 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