Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions internal/compiler/fileloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -265,6 +266,20 @@ func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReaso
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
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},
},
})
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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";

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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";

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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",
Expand Down

This file was deleted.

Loading