From 3978c474e56091723aaf8f1cdd621df8f4d7d35c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:22:13 +0000 Subject: [PATCH 1/8] Initial plan From 4a047d6e9562182aa1aba0f8f414a06bf7c6c194 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:44:42 +0000 Subject: [PATCH 2/8] Add missing TS6504 error for JS files without allowJs Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/fileloader.go | 15 ++++++ .../compiler/checkJsFiles6.errors.txt | 6 +++ .../compiler/checkJsFiles6.errors.txt.diff | 15 ------ ...eCompilationWithoutJsExtensions.errors.txt | 10 ++++ ...ilationWithoutJsExtensions.errors.txt.diff | 14 ------ ...ionsExcludesNode(module=esnext).errors.txt | 44 +++++++++++++++++ ...xcludesNode(module=esnext).errors.txt.diff | 48 ------------------- ...nsExcludesNode(module=preserve).errors.txt | 44 +++++++++++++++++ ...ludesNode(module=preserve).errors.txt.diff | 48 ------------------- ...dlerNodeModules1(module=esnext).errors.txt | 12 +++++ ...odeModules1(module=esnext).errors.txt.diff | 23 --------- ...erNodeModules1(module=preserve).errors.txt | 12 +++++ ...eModules1(module=preserve).errors.txt.diff | 23 --------- .../nodeModulesAtTypesPriority.errors.txt | 34 +++++++++++++ ...nodeModulesAtTypesPriority.errors.txt.diff | 38 --------------- ...cksTypesVersions(module=node16).errors.txt | 6 +++ ...pesVersions(module=node16).errors.txt.diff | 19 -------- ...cksTypesVersions(module=node18).errors.txt | 6 +++ ...pesVersions(module=node18).errors.txt.diff | 19 -------- ...cksTypesVersions(module=node20).errors.txt | 6 +++ ...pesVersions(module=node20).errors.txt.diff | 19 -------- ...sTypesVersions(module=nodenext).errors.txt | 6 +++ ...sVersions(module=nodenext).errors.txt.diff | 19 -------- ...stic1(moduleresolution=bundler).errors.txt | 24 ++++++++++ ...(moduleresolution=bundler).errors.txt.diff | 36 -------------- ...ostic1(moduleresolution=node16).errors.txt | 24 ++++++++++ ...1(moduleresolution=node16).errors.txt.diff | 38 --------------- 27 files changed, 249 insertions(+), 359 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt.diff diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index e1e84650d3..7aa69ad033 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -10,6 +10,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" @@ -265,6 +266,20 @@ func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReaso libFile: libFile, includeReason: includeReason, }) + } else if tspath.HasExtension(fileName) { + // File has an extension but it's not in the supported extensions list + // Check if it's a JavaScript file and report the appropriate diagnostic + canonicalFileName := tspath.GetCanonicalFileName(fileName, p.opts.Host.FS().UseCaseSensitiveFileNames()) + if tspath.HasJSFileExtension(canonicalFileName) { + p.includeProcessor.addProcessingDiagnostic(&processingDiagnostic{ + kind: processingDiagnosticKindExplainingFileInclude, + data: &includeExplainingDiagnostic{ + diagnosticReason: includeReason, + message: diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, + args: []any{fileName}, + }, + }) + } } } diff --git a/testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt index ebd8b9890d..64ee1083a7 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt @@ -1,6 +1,12 @@ error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. +error TS6504: File 'a.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation !!! error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. +!!! error TS6504: File 'a.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== a.js (0 errors) ==== var x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt.diff deleted file mode 100644 index 52a665c1b5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.checkJsFiles6.errors.txt -+++ new.checkJsFiles6.errors.txt -@@= skipped -0, +0 lines =@@ - error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. --error TS6504: File 'a.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - - - !!! error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. --!!! error TS6504: File 'a.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== a.js (0 errors) ==== - var x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt new file mode 100644 index 0000000000..080685f444 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt @@ -0,0 +1,10 @@ +error TS6504: File 'a.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation + + +!!! error TS6504: File 'a.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== a.js (0 errors) ==== + declare var v; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt.diff deleted file mode 100644 index aa5135ffa1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.jsFileCompilationWithoutJsExtensions.errors.txt -+++ new.jsFileCompilationWithoutJsExtensions.errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File 'a.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation -- -- --!!! error TS6504: File 'a.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --==== a.js (0 errors) ==== -- declare var v; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt b/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt new file mode 100644 index 0000000000..7a843cb155 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt @@ -0,0 +1,44 @@ +error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation + + +!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== /node_modules/conditions/package.json (0 errors) ==== + { + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +==== /node_modules/conditions/index.node.js (0 errors) ==== + export const node = 0; + +==== /node_modules/conditions/index.node.d.ts (0 errors) ==== + export const node: number; + +==== /node_modules/conditions/index.web.js (0 errors) ==== + export const web = 0; + +==== /node_modules/conditions/index.web.d.ts (0 errors) ==== + export const web: number; + +==== /main.ts (0 errors) ==== + import { web } from "conditions"; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt.diff deleted file mode 100644 index 6c7cacf0ed..0000000000 --- a/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- old.bundlerConditionsExcludesNode(module=esnext).errors.txt -+++ new.bundlerConditionsExcludesNode(module=esnext).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation -- -- --!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --==== /node_modules/conditions/package.json (0 errors) ==== -- { -- "name": "conditions", -- "version": "1.0.0", -- "type": "module", -- "main": "index.cjs", -- "types": "index.d.cts", -- "exports": { -- ".": { -- "node": "./index.node.js", -- "default": "./index.web.js" -- } -- } -- } -- --==== /node_modules/conditions/index.node.js (0 errors) ==== -- export const node = 0; -- --==== /node_modules/conditions/index.node.d.ts (0 errors) ==== -- export const node: number; -- --==== /node_modules/conditions/index.web.js (0 errors) ==== -- export const web = 0; -- --==== /node_modules/conditions/index.web.d.ts (0 errors) ==== -- export const web: number; -- --==== /main.ts (0 errors) ==== -- import { web } from "conditions"; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt b/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt new file mode 100644 index 0000000000..7a843cb155 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt @@ -0,0 +1,44 @@ +error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation + + +!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== /node_modules/conditions/package.json (0 errors) ==== + { + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +==== /node_modules/conditions/index.node.js (0 errors) ==== + export const node = 0; + +==== /node_modules/conditions/index.node.d.ts (0 errors) ==== + export const node: number; + +==== /node_modules/conditions/index.web.js (0 errors) ==== + export const web = 0; + +==== /node_modules/conditions/index.web.d.ts (0 errors) ==== + export const web: number; + +==== /main.ts (0 errors) ==== + import { web } from "conditions"; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt.diff deleted file mode 100644 index 4eb014059c..0000000000 --- a/testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- old.bundlerConditionsExcludesNode(module=preserve).errors.txt -+++ new.bundlerConditionsExcludesNode(module=preserve).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation -- -- --!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --==== /node_modules/conditions/package.json (0 errors) ==== -- { -- "name": "conditions", -- "version": "1.0.0", -- "type": "module", -- "main": "index.cjs", -- "types": "index.d.cts", -- "exports": { -- ".": { -- "node": "./index.node.js", -- "default": "./index.web.js" -- } -- } -- } -- --==== /node_modules/conditions/index.node.js (0 errors) ==== -- export const node = 0; -- --==== /node_modules/conditions/index.node.d.ts (0 errors) ==== -- export const node: number; -- --==== /node_modules/conditions/index.web.js (0 errors) ==== -- export const web = 0; -- --==== /node_modules/conditions/index.web.d.ts (0 errors) ==== -- export const web: number; -- --==== /main.ts (0 errors) ==== -- import { web } from "conditions"; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt b/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt index 7b37a0edde..b25d226dac 100644 --- a/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt @@ -1,8 +1,20 @@ +error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation /main.cts(1,10): error TS2305: Module '"dual"' has no exported member 'esm'. /main.mts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. /main.ts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. +!!! error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== /node_modules/dual/package.json (0 errors) ==== { "name": "dual", diff --git a/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt.diff deleted file mode 100644 index 03de766a92..0000000000 --- a/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.bundlerNodeModules1(module=esnext).errors.txt -+++ new.bundlerNodeModules1(module=esnext).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - /main.cts(1,10): error TS2305: Module '"dual"' has no exported member 'esm'. - /main.mts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. - /main.ts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. - - --!!! error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== /node_modules/dual/package.json (0 errors) ==== - { - "name": "dual", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt b/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt index 7b37a0edde..b25d226dac 100644 --- a/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt @@ -1,8 +1,20 @@ +error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation /main.cts(1,10): error TS2305: Module '"dual"' has no exported member 'esm'. /main.mts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. /main.ts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. +!!! error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== /node_modules/dual/package.json (0 errors) ==== { "name": "dual", diff --git a/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt.diff deleted file mode 100644 index d957e01b34..0000000000 --- a/testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.bundlerNodeModules1(module=preserve).errors.txt -+++ new.bundlerNodeModules1(module=preserve).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - /main.cts(1,10): error TS2305: Module '"dual"' has no exported member 'esm'. - /main.mts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. - /main.ts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. - - --!!! error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== /node_modules/dual/package.json (0 errors) ==== - { - "name": "dual", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt new file mode 100644 index 0000000000..0f30543054 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt @@ -0,0 +1,34 @@ +error TS6504: File '/packages/a/node_modules/react/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/packages/a/node_modules/redux/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation + + +!!! error TS6504: File '/packages/a/node_modules/react/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/packages/a/node_modules/redux/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== /node_modules/@types/react/index.d.ts (0 errors) ==== + declare const React: any; + export = React; + +==== /node_modules/@types/redux/index.d.ts (0 errors) ==== + export declare function createStore(): void; + +==== /packages/a/node_modules/react/index.js (0 errors) ==== + module.exports = {}; + +==== /packages/a/node_modules/redux/index.d.ts (0 errors) ==== + export declare function createStore(): void; + +==== /packages/a/node_modules/redux/index.js (0 errors) ==== + module.exports = {}; + +==== /packages/a/index.ts (0 errors) ==== + import React from "react"; + import { createStore } from "redux"; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt.diff deleted file mode 100644 index eade98ce48..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.nodeModulesAtTypesPriority.errors.txt -+++ new.nodeModulesAtTypesPriority.errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/packages/a/node_modules/react/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/packages/a/node_modules/redux/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation -- -- --!!! error TS6504: File '/packages/a/node_modules/react/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/packages/a/node_modules/redux/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --==== /node_modules/@types/react/index.d.ts (0 errors) ==== -- declare const React: any; -- export = React; -- --==== /node_modules/@types/redux/index.d.ts (0 errors) ==== -- export declare function createStore(): void; -- --==== /packages/a/node_modules/react/index.js (0 errors) ==== -- module.exports = {}; -- --==== /packages/a/node_modules/redux/index.d.ts (0 errors) ==== -- export declare function createStore(): void; -- --==== /packages/a/node_modules/redux/index.js (0 errors) ==== -- module.exports = {}; -- --==== /packages/a/index.ts (0 errors) ==== -- import React from "react"; -- import { createStore } from "redux"; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt index 8300f6aaaa..a0ed330173 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt @@ -1,3 +1,6 @@ +error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation /main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` /main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. @@ -8,6 +11,9 @@ /main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. +!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== { "name": "exports-and-types-versions", diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt.diff deleted file mode 100644 index f21056a46c..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt -+++ new.nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - /main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. - If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` - /main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. -@@= skipped -10, +7 lines =@@ - /main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. - - --!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== - { - "name": "exports-and-types-versions", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt index 8300f6aaaa..a0ed330173 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt @@ -1,3 +1,6 @@ +error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation /main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` /main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. @@ -8,6 +11,9 @@ /main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. +!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== { "name": "exports-and-types-versions", diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt.diff deleted file mode 100644 index a4906f98e3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt -+++ new.nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - /main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. - If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` - /main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. -@@= skipped -10, +7 lines =@@ - /main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. - - --!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== - { - "name": "exports-and-types-versions", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt index 8300f6aaaa..a0ed330173 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt @@ -1,3 +1,6 @@ +error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation /main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` /main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. @@ -8,6 +11,9 @@ /main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. +!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== { "name": "exports-and-types-versions", diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt.diff deleted file mode 100644 index 70c6cfa3d3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt -+++ new.nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - /main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. - If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` - /main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. -@@= skipped -10, +7 lines =@@ - /main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. - - --!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== - { - "name": "exports-and-types-versions", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt index 8300f6aaaa..a0ed330173 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt @@ -1,3 +1,6 @@ +error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation /main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` /main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. @@ -8,6 +11,9 @@ /main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. +!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== { "name": "exports-and-types-versions", diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt.diff deleted file mode 100644 index 32caba6b9f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt -+++ new.nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - /main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. - If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` - /main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. -@@= skipped -10, +7 lines =@@ - /main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. - - --!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== - { - "name": "exports-and-types-versions", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt b/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt index c282ce8a1f..fe904ca695 100644 --- a/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt @@ -1,9 +1,33 @@ +error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/bar/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/foo/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation /index.mts(1,21): error TS7016: Could not find a declaration file for module 'foo'. '/node_modules/foo/index.mjs' implicitly has an 'any' type. There are types at '/node_modules/foo/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'foo' library may need to update its package.json or typings. /index.mts(2,21): error TS7016: Could not find a declaration file for module 'bar'. '/node_modules/bar/index.mjs' implicitly has an 'any' type. There are types at '/node_modules/@types/bar/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@types/bar' library may need to update its package.json or typings. +!!! error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/bar/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/foo/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== /node_modules/foo/package.json (0 errors) ==== { "name": "foo", diff --git a/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt.diff deleted file mode 100644 index a2bc1e8d1e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt -+++ new.resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt -@@= skipped -0, +0 lines =@@ --error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/bar/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/foo/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - /index.mts(1,21): error TS7016: Could not find a declaration file for module 'foo'. '/node_modules/foo/index.mjs' implicitly has an 'any' type. - There are types at '/node_modules/foo/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'foo' library may need to update its package.json or typings. - /index.mts(2,21): error TS7016: Could not find a declaration file for module 'bar'. '/node_modules/bar/index.mjs' implicitly has an 'any' type. - There are types at '/node_modules/@types/bar/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@types/bar' library may need to update its package.json or typings. - - --!!! error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/bar/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/foo/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== /node_modules/foo/package.json (0 errors) ==== - { - "name": "foo", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt index cc9f7f36f2..7fa0a30235 100644 --- a/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt @@ -1,4 +1,16 @@ error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/bar/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/foo/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation /index.mts(1,21): error TS7016: Could not find a declaration file for module 'foo'. '/node_modules/foo/index.mjs' implicitly has an 'any' type. There are types at '/node_modules/foo/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'foo' library may need to update its package.json or typings. /index.mts(2,21): error TS7016: Could not find a declaration file for module 'bar'. '/node_modules/bar/index.mjs' implicitly has an 'any' type. @@ -6,6 +18,18 @@ error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolut !!! error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +!!! error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/bar/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/foo/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation ==== /node_modules/foo/package.json (0 errors) ==== { "name": "foo", diff --git a/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt.diff deleted file mode 100644 index fc9652b0df..0000000000 --- a/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt -+++ new.resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt -@@= skipped -0, +0 lines =@@ - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. --error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/bar/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/foo/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation --error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? -- The file is in the program because: -- Root file specified for compilation - /index.mts(1,21): error TS7016: Could not find a declaration file for module 'foo'. '/node_modules/foo/index.mjs' implicitly has an 'any' type. - There are types at '/node_modules/foo/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'foo' library may need to update its package.json or typings. - /index.mts(2,21): error TS7016: Could not find a declaration file for module 'bar'. '/node_modules/bar/index.mjs' implicitly has an 'any' type. -@@= skipped -17, +5 lines =@@ - - - !!! error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. --!!! error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/bar/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/foo/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation --!!! error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? --!!! error TS6504: The file is in the program because: --!!! error TS6504: Root file specified for compilation - ==== /node_modules/foo/package.json (0 errors) ==== - { - "name": "foo", \ No newline at end of file From ae117351c82e33769381dc7cbbcd1a096133a728 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 19 Nov 2025 12:58:37 -0800 Subject: [PATCH 3/8] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- internal/compiler/fileloader.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 7aa69ad033..d460f86480 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -266,10 +266,10 @@ func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReaso libFile: libFile, includeReason: includeReason, }) - } else if tspath.HasExtension(fileName) { + } else if tspath.HasExtension(absPath) { // File has an extension but it's not in the supported extensions list // Check if it's a JavaScript file and report the appropriate diagnostic - canonicalFileName := tspath.GetCanonicalFileName(fileName, p.opts.Host.FS().UseCaseSensitiveFileNames()) + canonicalFileName := tspath.GetCanonicalFileName(absPath, p.opts.Host.FS().UseCaseSensitiveFileNames()) if tspath.HasJSFileExtension(canonicalFileName) { p.includeProcessor.addProcessingDiagnostic(&processingDiagnostic{ kind: processingDiagnosticKindExplainingFileInclude, From b07f77bd109ccb6c0572eb58840d8d9281a0126c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:54:33 +0000 Subject: [PATCH 4/8] Move JS file diagnostic check to common file loading path Moved the TS6504 diagnostic check from addRootTask to parseTask.load() so it catches all file inclusion paths (root files, triple-slash refs, type refs, etc.), not just root files. This matches TypeScript's behavior where getSourceFileFromReferenceWorker is called for all file types. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/fileloader.go | 22 ++++++++++----------- internal/compiler/filesparser.go | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index d460f86480..b49d403af6 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -10,7 +10,6 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" @@ -260,6 +259,8 @@ func (p *fileLoader) toPath(file string) tspath.Path { func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReason *FileIncludeReason) { absPath := tspath.GetNormalizedAbsolutePath(fileName, p.opts.Host.GetCurrentDirectory()) + // Check if file should be included based on extension + // This mirrors the logic from getSourceFileFromReferenceWorker in TypeScript if core.Tristate.IsTrue(p.opts.Config.CompilerOptions().AllowNonTsExtensions) || slices.Contains(p.supportedExtensions, tspath.TryGetExtensionFromPath(absPath)) { p.rootTasks = append(p.rootTasks, &parseTask{ normalizedFilePath: absPath, @@ -269,17 +270,14 @@ func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReaso } else if tspath.HasExtension(absPath) { // File has an extension but it's not in the supported extensions list // Check if it's a JavaScript file and report the appropriate diagnostic - canonicalFileName := tspath.GetCanonicalFileName(absPath, p.opts.Host.FS().UseCaseSensitiveFileNames()) - if tspath.HasJSFileExtension(canonicalFileName) { - p.includeProcessor.addProcessingDiagnostic(&processingDiagnostic{ - kind: processingDiagnosticKindExplainingFileInclude, - data: &includeExplainingDiagnostic{ - diagnosticReason: includeReason, - message: diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, - args: []any{fileName}, - }, - }) - } + // This will be caught later in parseTask.load() for consistency with other file inclusion paths + // But for root files, we need to add them to rootTasks so they can be processed + // The diagnostic will be reported in load() before attempting to parse + p.rootTasks = append(p.rootTasks, &parseTask{ + normalizedFilePath: absPath, + libFile: libFile, + includeReason: includeReason, + }) } } diff --git a/internal/compiler/filesparser.go b/internal/compiler/filesparser.go index abf767ed34..8cd0b5c570 100644 --- a/internal/compiler/filesparser.go +++ b/internal/compiler/filesparser.go @@ -7,6 +7,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" @@ -68,6 +69,38 @@ func (t *parseTask) load(loader *fileLoader) { return } + // Check if file has unsupported extension (similar to getSourceFileFromReferenceWorker in TypeScript) + // Do this check before incrementing file counts + if tspath.HasExtension(t.normalizedFilePath) { + compilerOptions := loader.opts.Config.CompilerOptions() + allowNonTsExtensions := core.Tristate.IsTrue(compilerOptions.AllowNonTsExtensions) + if !allowNonTsExtensions { + canonicalFileName := tspath.GetCanonicalFileName(t.normalizedFilePath, loader.opts.Host.FS().UseCaseSensitiveFileNames()) + supported := false + for _, ext := range loader.supportedExtensions { + if tspath.FileExtensionIs(canonicalFileName, ext) { + supported = true + break + } + } + if !supported { + // Report appropriate diagnostic for unsupported extension + if tspath.HasJSFileExtension(canonicalFileName) { + loader.includeProcessor.addProcessingDiagnostic(&processingDiagnostic{ + kind: processingDiagnosticKindExplainingFileInclude, + data: &includeExplainingDiagnostic{ + diagnosticReason: t.includeReason, + message: diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, + args: []any{t.normalizedFilePath}, + }, + }) + } + // File has unsupported extension, don't try to parse it + return + } + } + } + loader.totalFileCount.Add(1) if t.libFile != nil { loader.libFileCount.Add(1) From d1c8f3bc04e235db07e72a94091ac25146c9859c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Dec 2025 03:38:30 +0000 Subject: [PATCH 5/8] Fix data race in includeProcessor Added mutex protection to includeProcessor to prevent concurrent access to processingDiagnostics and fileIncludeReasons. The data race was occurring when multiple goroutines in parseTask.load() called addProcessingDiagnostic simultaneously. Changes: - Added mu sync.Mutex to includeProcessor struct - Protected all reads/writes to processingDiagnostics with mutex - Protected all reads/writes to fileIncludeReasons with mutex - Added addFileIncludeReason() and getFileIncludeReasons() helper methods - Updated all direct field accesses to use protected methods - Used maps.Copy in GetIncludeReasons() as suggested by linter Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/filesparser.go | 6 +---- internal/compiler/includeprocessor.go | 30 ++++++++++++++++++++--- internal/compiler/processingDiagnostic.go | 2 +- internal/compiler/program.go | 9 +++++-- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/internal/compiler/filesparser.go b/internal/compiler/filesparser.go index 0fa36c3ee1..89c11eae05 100644 --- a/internal/compiler/filesparser.go +++ b/internal/compiler/filesparser.go @@ -427,10 +427,6 @@ func (w *filesParser) addIncludeReason(loader *fileLoader, task *parseTask, reas if task.redirectedParseTask != nil { w.addIncludeReason(loader, task.redirectedParseTask, reason) } else if task.loaded { - if existing, ok := loader.includeProcessor.fileIncludeReasons[task.path]; ok { - loader.includeProcessor.fileIncludeReasons[task.path] = append(existing, reason) - } else { - loader.includeProcessor.fileIncludeReasons[task.path] = []*FileIncludeReason{reason} - } + loader.includeProcessor.addFileIncludeReason(task.path, reason) } } diff --git a/internal/compiler/includeprocessor.go b/internal/compiler/includeprocessor.go index a40534bbde..4d251432d4 100644 --- a/internal/compiler/includeprocessor.go +++ b/internal/compiler/includeprocessor.go @@ -15,6 +15,7 @@ import ( type includeProcessor struct { fileIncludeReasons map[tspath.Path][]*FileIncludeReason processingDiagnostics []*processingDiagnostic + mu sync.Mutex // protects fileIncludeReasons and processingDiagnostics reasonToReferenceLocation collections.SyncMap[*FileIncludeReason, *referenceFileLocation] includeReasonToRelatedInfo collections.SyncMap[*FileIncludeReason, *ast.Diagnostic] @@ -35,7 +36,13 @@ func updateFileIncludeProcessor(p *Program) { func (i *includeProcessor) getDiagnostics(p *Program) *ast.DiagnosticsCollection { i.computedDiagnosticsOnce.Do(func() { i.computedDiagnostics = &ast.DiagnosticsCollection{} - for _, d := range i.processingDiagnostics { + + i.mu.Lock() + diagnostics := make([]*processingDiagnostic, len(i.processingDiagnostics)) + copy(diagnostics, i.processingDiagnostics) + i.mu.Unlock() + + for _, d := range diagnostics { i.computedDiagnostics.Add(d.toDiagnostic(p)) } for _, resolutions := range p.resolvedModules { @@ -57,14 +64,31 @@ func (i *includeProcessor) getDiagnostics(p *Program) *ast.DiagnosticsCollection } func (i *includeProcessor) addProcessingDiagnostic(d ...*processingDiagnostic) { + i.mu.Lock() + defer i.mu.Unlock() i.processingDiagnostics = append(i.processingDiagnostics, d...) } +func (i *includeProcessor) addFileIncludeReason(path tspath.Path, reason *FileIncludeReason) { + i.mu.Lock() + defer i.mu.Unlock() + i.fileIncludeReasons[path] = append(i.fileIncludeReasons[path], reason) +} + +func (i *includeProcessor) getFileIncludeReasons(path tspath.Path) []*FileIncludeReason { + i.mu.Lock() + defer i.mu.Unlock() + return i.fileIncludeReasons[path] +} + func (i *includeProcessor) addProcessingDiagnosticsForFileCasing(file tspath.Path, existingCasing string, currentCasing string, reason *FileIncludeReason) { + i.mu.Lock() + defer i.mu.Unlock() + if !reason.isReferencedFile() && slices.ContainsFunc(i.fileIncludeReasons[file], func(r *FileIncludeReason) bool { return r.isReferencedFile() }) { - i.addProcessingDiagnostic(&processingDiagnostic{ + i.processingDiagnostics = append(i.processingDiagnostics, &processingDiagnostic{ kind: processingDiagnosticKindExplainingFileInclude, data: &includeExplainingDiagnostic{ file: file, @@ -74,7 +98,7 @@ func (i *includeProcessor) addProcessingDiagnosticsForFileCasing(file tspath.Pat }, }) } else { - i.addProcessingDiagnostic(&processingDiagnostic{ + i.processingDiagnostics = append(i.processingDiagnostics, &processingDiagnostic{ kind: processingDiagnosticKindExplainingFileInclude, data: &includeExplainingDiagnostic{ file: file, diff --git a/internal/compiler/processingDiagnostic.go b/internal/compiler/processingDiagnostic.go index a2f7d89e90..8656472710 100644 --- a/internal/compiler/processingDiagnostic.go +++ b/internal/compiler/processingDiagnostic.go @@ -97,7 +97,7 @@ func (d *processingDiagnostic) createDiagnosticExplainingFile(program *Program) // !!! todo sheetal caching if diag.file != "" { - reasons := program.includeProcessor.fileIncludeReasons[diag.file] + reasons := program.includeProcessor.getFileIncludeReasons(diag.file) includeDetails = make([]*ast.Diagnostic, 0, len(reasons)) for _, reason := range reasons { processInclude(reason) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 5806c6b713..f1ec819b11 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -1562,7 +1562,12 @@ func (p *Program) GetSourceFiles() []*ast.SourceFile { // Testing only func (p *Program) GetIncludeReasons() map[tspath.Path][]*FileIncludeReason { - return p.includeProcessor.fileIncludeReasons + p.includeProcessor.mu.Lock() + defer p.includeProcessor.mu.Unlock() + // Return a copy to avoid concurrent access issues + result := make(map[tspath.Path][]*FileIncludeReason, len(p.includeProcessor.fileIncludeReasons)) + maps.Copy(result, p.includeProcessor.fileIncludeReasons) + return result } // Testing only @@ -1578,7 +1583,7 @@ func (p *Program) ExplainFiles(w io.Writer, locale locale.Locale) { } for _, file := range p.GetSourceFiles() { fmt.Fprintln(w, toRelativeFileName(file.FileName())) - for _, reason := range p.includeProcessor.fileIncludeReasons[file.Path()] { + for _, reason := range p.includeProcessor.getFileIncludeReasons(file.Path()) { fmt.Fprintln(w, " ", reason.toDiagnostic(p, true).Localize(locale)) } for _, diag := range p.includeProcessor.explainRedirectAndImpliedFormat(p, file, toRelativeFileName) { From df97f087ecf3d8f69703c37c8fae602336baf0a3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Dec 2025 20:06:25 +0000 Subject: [PATCH 6/8] Store diagnostics on parseTask instead of using locks Per review feedback, changed approach to avoid locks: - Added processingDiagnostics field to parseTask struct - Store diagnostics on task during parallel load phase - Add diagnostics to includeProcessor during sequential collection phase - Removed mutex from includeProcessor (no longer needed) - Simplified addRootTask condition to: allowNonTsExtensions OR hasExtension - This avoids data races and prevents adding diagnostics for excluded tasks Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/fileloader.go | 18 ++++-------------- internal/compiler/filesparser.go | 11 +++++++++-- internal/compiler/includeprocessor.go | 18 +----------------- internal/compiler/program.go | 7 +------ 4 files changed, 15 insertions(+), 39 deletions(-) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index bdb2f0383e..669af428ee 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -144,20 +144,10 @@ func (p *fileLoader) toPath(file string) tspath.Path { func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReason *FileIncludeReason) { absPath := tspath.GetNormalizedAbsolutePath(fileName, p.opts.Host.GetCurrentDirectory()) - // Check if file should be included based on extension - // This mirrors the logic from getSourceFileFromReferenceWorker in TypeScript - if core.Tristate.IsTrue(p.opts.Config.CompilerOptions().AllowNonTsExtensions) || slices.Contains(p.supportedExtensions, tspath.TryGetExtensionFromPath(absPath)) { - p.rootTasks = append(p.rootTasks, &parseTask{ - normalizedFilePath: absPath, - libFile: libFile, - includeReason: includeReason, - }) - } else if tspath.HasExtension(absPath) { - // File has an extension but it's not in the supported extensions list - // Check if it's a JavaScript file and report the appropriate diagnostic - // This will be caught later in parseTask.load() for consistency with other file inclusion paths - // But for root files, we need to add them to rootTasks so they can be processed - // The diagnostic will be reported in load() before attempting to parse + // Add task if allowNonTsExtensions is true OR if the file has an extension + // Files with extensions will be validated in parseTask.load() to check if they're supported + // and report appropriate diagnostics for unsupported file types (e.g., JS files without allowJs) + if core.Tristate.IsTrue(p.opts.Config.CompilerOptions().AllowNonTsExtensions) || tspath.HasExtension(absPath) { p.rootTasks = append(p.rootTasks, &parseTask{ normalizedFilePath: absPath, libFile: libFile, diff --git a/internal/compiler/filesparser.go b/internal/compiler/filesparser.go index 89c11eae05..985c53a26d 100644 --- a/internal/compiler/filesparser.go +++ b/internal/compiler/filesparser.go @@ -32,6 +32,7 @@ type parseTask struct { typeResolutionsInFile module.ModeAwareCache[*module.ResolvedTypeReferenceDirective] typeResolutionsTrace []module.DiagAndArgs resolutionDiagnostics []*ast.Diagnostic + processingDiagnostics []*processingDiagnostic importHelpersImportSpecifier *ast.Node jsxRuntimeImportSpecifier *jsxRuntimeImportSpecifier @@ -77,9 +78,9 @@ func (t *parseTask) load(loader *fileLoader) { } } if !supported { - // Report appropriate diagnostic for unsupported extension + // Store diagnostic on task - it will be added to includeProcessor during collection phase if tspath.HasJSFileExtension(canonicalFileName) { - loader.includeProcessor.addProcessingDiagnostic(&processingDiagnostic{ + t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{ kind: processingDiagnosticKindExplainingFileInclude, data: &includeExplainingDiagnostic{ diagnosticReason: t.includeReason, @@ -352,6 +353,12 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles { } file := task.file path := task.path + + // Add any processing diagnostics from this task to the includeProcessor + if len(task.processingDiagnostics) > 0 { + loader.includeProcessor.processingDiagnostics = append(loader.includeProcessor.processingDiagnostics, task.processingDiagnostics...) + } + if file == nil { // !!! sheetal file preprocessing diagnostic explaining getSourceFileFromReferenceWorker missingFiles = append(missingFiles, task.normalizedFilePath) diff --git a/internal/compiler/includeprocessor.go b/internal/compiler/includeprocessor.go index 4d251432d4..31b7052646 100644 --- a/internal/compiler/includeprocessor.go +++ b/internal/compiler/includeprocessor.go @@ -15,7 +15,6 @@ import ( type includeProcessor struct { fileIncludeReasons map[tspath.Path][]*FileIncludeReason processingDiagnostics []*processingDiagnostic - mu sync.Mutex // protects fileIncludeReasons and processingDiagnostics reasonToReferenceLocation collections.SyncMap[*FileIncludeReason, *referenceFileLocation] includeReasonToRelatedInfo collections.SyncMap[*FileIncludeReason, *ast.Diagnostic] @@ -36,13 +35,7 @@ func updateFileIncludeProcessor(p *Program) { func (i *includeProcessor) getDiagnostics(p *Program) *ast.DiagnosticsCollection { i.computedDiagnosticsOnce.Do(func() { i.computedDiagnostics = &ast.DiagnosticsCollection{} - - i.mu.Lock() - diagnostics := make([]*processingDiagnostic, len(i.processingDiagnostics)) - copy(diagnostics, i.processingDiagnostics) - i.mu.Unlock() - - for _, d := range diagnostics { + for _, d := range i.processingDiagnostics { i.computedDiagnostics.Add(d.toDiagnostic(p)) } for _, resolutions := range p.resolvedModules { @@ -64,27 +57,18 @@ func (i *includeProcessor) getDiagnostics(p *Program) *ast.DiagnosticsCollection } func (i *includeProcessor) addProcessingDiagnostic(d ...*processingDiagnostic) { - i.mu.Lock() - defer i.mu.Unlock() i.processingDiagnostics = append(i.processingDiagnostics, d...) } func (i *includeProcessor) addFileIncludeReason(path tspath.Path, reason *FileIncludeReason) { - i.mu.Lock() - defer i.mu.Unlock() i.fileIncludeReasons[path] = append(i.fileIncludeReasons[path], reason) } func (i *includeProcessor) getFileIncludeReasons(path tspath.Path) []*FileIncludeReason { - i.mu.Lock() - defer i.mu.Unlock() return i.fileIncludeReasons[path] } func (i *includeProcessor) addProcessingDiagnosticsForFileCasing(file tspath.Path, existingCasing string, currentCasing string, reason *FileIncludeReason) { - i.mu.Lock() - defer i.mu.Unlock() - if !reason.isReferencedFile() && slices.ContainsFunc(i.fileIncludeReasons[file], func(r *FileIncludeReason) bool { return r.isReferencedFile() }) { diff --git a/internal/compiler/program.go b/internal/compiler/program.go index f1ec819b11..1a671e8c62 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -1562,12 +1562,7 @@ func (p *Program) GetSourceFiles() []*ast.SourceFile { // Testing only func (p *Program) GetIncludeReasons() map[tspath.Path][]*FileIncludeReason { - p.includeProcessor.mu.Lock() - defer p.includeProcessor.mu.Unlock() - // Return a copy to avoid concurrent access issues - result := make(map[tspath.Path][]*FileIncludeReason, len(p.includeProcessor.fileIncludeReasons)) - maps.Copy(result, p.includeProcessor.fileIncludeReasons) - return result + return p.includeProcessor.fileIncludeReasons } // Testing only From 33f9059318ef0e95cb970a4231d00491a95acf4d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 3 Dec 2025 12:23:58 -0800 Subject: [PATCH 7/8] cleanup --- internal/compiler/fileloader.go | 5 +---- internal/compiler/filesparser.go | 7 +------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 669af428ee..c32a381896 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -144,10 +144,7 @@ func (p *fileLoader) toPath(file string) tspath.Path { func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReason *FileIncludeReason) { absPath := tspath.GetNormalizedAbsolutePath(fileName, p.opts.Host.GetCurrentDirectory()) - // Add task if allowNonTsExtensions is true OR if the file has an extension - // Files with extensions will be validated in parseTask.load() to check if they're supported - // and report appropriate diagnostics for unsupported file types (e.g., JS files without allowJs) - if core.Tristate.IsTrue(p.opts.Config.CompilerOptions().AllowNonTsExtensions) || tspath.HasExtension(absPath) { + if p.opts.Config.CompilerOptions().AllowNonTsExtensions.IsTrue() || tspath.HasExtension(absPath) { p.rootTasks = append(p.rootTasks, &parseTask{ normalizedFilePath: absPath, libFile: libFile, diff --git a/internal/compiler/filesparser.go b/internal/compiler/filesparser.go index 985c53a26d..e3c4d45339 100644 --- a/internal/compiler/filesparser.go +++ b/internal/compiler/filesparser.go @@ -63,11 +63,9 @@ func (t *parseTask) load(loader *fileLoader) { return } - // Check if file has unsupported extension (similar to getSourceFileFromReferenceWorker in TypeScript) - // Do this check before incrementing file counts if tspath.HasExtension(t.normalizedFilePath) { compilerOptions := loader.opts.Config.CompilerOptions() - allowNonTsExtensions := core.Tristate.IsTrue(compilerOptions.AllowNonTsExtensions) + allowNonTsExtensions := compilerOptions.AllowNonTsExtensions.IsTrue() if !allowNonTsExtensions { canonicalFileName := tspath.GetCanonicalFileName(t.normalizedFilePath, loader.opts.Host.FS().UseCaseSensitiveFileNames()) supported := false @@ -78,7 +76,6 @@ func (t *parseTask) load(loader *fileLoader) { } } if !supported { - // Store diagnostic on task - it will be added to includeProcessor during collection phase if tspath.HasJSFileExtension(canonicalFileName) { t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{ kind: processingDiagnosticKindExplainingFileInclude, @@ -89,7 +86,6 @@ func (t *parseTask) load(loader *fileLoader) { }, }) } - // File has unsupported extension, don't try to parse it return } } @@ -354,7 +350,6 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles { file := task.file path := task.path - // Add any processing diagnostics from this task to the includeProcessor if len(task.processingDiagnostics) > 0 { loader.includeProcessor.processingDiagnostics = append(loader.includeProcessor.processingDiagnostics, task.processingDiagnostics...) } From 1c0be187871d05f95f08681263b89759ee521f5f Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 3 Dec 2025 12:25:49 -0800 Subject: [PATCH 8/8] reverts --- internal/compiler/filesparser.go | 6 +++++- internal/compiler/includeprocessor.go | 12 ++---------- internal/compiler/processingDiagnostic.go | 2 +- internal/compiler/program.go | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/internal/compiler/filesparser.go b/internal/compiler/filesparser.go index e3c4d45339..64a2c8dcd7 100644 --- a/internal/compiler/filesparser.go +++ b/internal/compiler/filesparser.go @@ -429,6 +429,10 @@ func (w *filesParser) addIncludeReason(loader *fileLoader, task *parseTask, reas if task.redirectedParseTask != nil { w.addIncludeReason(loader, task.redirectedParseTask, reason) } else if task.loaded { - loader.includeProcessor.addFileIncludeReason(task.path, reason) + if existing, ok := loader.includeProcessor.fileIncludeReasons[task.path]; ok { + loader.includeProcessor.fileIncludeReasons[task.path] = append(existing, reason) + } else { + loader.includeProcessor.fileIncludeReasons[task.path] = []*FileIncludeReason{reason} + } } } diff --git a/internal/compiler/includeprocessor.go b/internal/compiler/includeprocessor.go index 31b7052646..a40534bbde 100644 --- a/internal/compiler/includeprocessor.go +++ b/internal/compiler/includeprocessor.go @@ -60,19 +60,11 @@ func (i *includeProcessor) addProcessingDiagnostic(d ...*processingDiagnostic) { i.processingDiagnostics = append(i.processingDiagnostics, d...) } -func (i *includeProcessor) addFileIncludeReason(path tspath.Path, reason *FileIncludeReason) { - i.fileIncludeReasons[path] = append(i.fileIncludeReasons[path], reason) -} - -func (i *includeProcessor) getFileIncludeReasons(path tspath.Path) []*FileIncludeReason { - return i.fileIncludeReasons[path] -} - func (i *includeProcessor) addProcessingDiagnosticsForFileCasing(file tspath.Path, existingCasing string, currentCasing string, reason *FileIncludeReason) { if !reason.isReferencedFile() && slices.ContainsFunc(i.fileIncludeReasons[file], func(r *FileIncludeReason) bool { return r.isReferencedFile() }) { - i.processingDiagnostics = append(i.processingDiagnostics, &processingDiagnostic{ + i.addProcessingDiagnostic(&processingDiagnostic{ kind: processingDiagnosticKindExplainingFileInclude, data: &includeExplainingDiagnostic{ file: file, @@ -82,7 +74,7 @@ func (i *includeProcessor) addProcessingDiagnosticsForFileCasing(file tspath.Pat }, }) } else { - i.processingDiagnostics = append(i.processingDiagnostics, &processingDiagnostic{ + i.addProcessingDiagnostic(&processingDiagnostic{ kind: processingDiagnosticKindExplainingFileInclude, data: &includeExplainingDiagnostic{ file: file, diff --git a/internal/compiler/processingDiagnostic.go b/internal/compiler/processingDiagnostic.go index 8656472710..a2f7d89e90 100644 --- a/internal/compiler/processingDiagnostic.go +++ b/internal/compiler/processingDiagnostic.go @@ -97,7 +97,7 @@ func (d *processingDiagnostic) createDiagnosticExplainingFile(program *Program) // !!! todo sheetal caching if diag.file != "" { - reasons := program.includeProcessor.getFileIncludeReasons(diag.file) + reasons := program.includeProcessor.fileIncludeReasons[diag.file] includeDetails = make([]*ast.Diagnostic, 0, len(reasons)) for _, reason := range reasons { processInclude(reason) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 1a671e8c62..5806c6b713 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -1578,7 +1578,7 @@ func (p *Program) ExplainFiles(w io.Writer, locale locale.Locale) { } for _, file := range p.GetSourceFiles() { fmt.Fprintln(w, toRelativeFileName(file.FileName())) - for _, reason := range p.includeProcessor.getFileIncludeReasons(file.Path()) { + for _, reason := range p.includeProcessor.fileIncludeReasons[file.Path()] { fmt.Fprintln(w, " ", reason.toDiagnostic(p, true).Localize(locale)) } for _, diag := range p.includeProcessor.explainRedirectAndImpliedFormat(p, file, toRelativeFileName) {