-
Notifications
You must be signed in to change notification settings - Fork 744
Add missing TS6504 diagnostic for JavaScript files without allowJs #2104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
4
commits into
main
Choose a base branch
from
copilot/fix-missing-error-when-js-file
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
15 changes: 0 additions & 15 deletions
15
testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt.diff
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...ta/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
14 changes: 0 additions & 14 deletions
14
...selines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt.diff
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...s/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; | ||
|
|
48 changes: 0 additions & 48 deletions
48
...erence/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt.diff
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; | ||
|
|
48 changes: 0 additions & 48 deletions
48
...ence/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt.diff
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...a/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...elines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt.diff
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good but arent we currently checking this only for root files and not for resolved triple slash refs or project reference files etc as we did in strada
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true; Strada had this in
getSourceFileFromReferenceWorkerwhich was called byprocessSourceFile, so we do need to do this somewhere else.Let's try this for fun:
@copilot Reexamine program.ts's getSourceFileFromReferenceWorker, callers, etc, and place this check in the correct place in the Go implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in b07f77b. Moved the check from
addRootTasktoparseTask.load()so it now catches all file inclusion paths (root files, triple-slash references, type references, etc.). Tested with bothtsgo a.jsand triple-slash references like/// <reference path="helper.js" />- both now correctly report TS6504.