-
Notifications
You must be signed in to change notification settings - Fork 740
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
jakebailey
left a comment
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.
I think this seems fine?
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.
Pull Request Overview
This PR adds the missing TS6504 diagnostic for JavaScript files compiled without the allowJs option enabled. Previously, tsgo silently ignored these files while tsc reports a helpful error message, making tsgo less user-friendly.
Key Changes
- Modified
internal/compiler/fileloader.goto detect JavaScript files and report TS6504 diagnostic whenallowJsis not enabled - Updated 26 test baseline files to reflect the new behavior, showing convergence with TypeScript's behavior
Reviewed Changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/compiler/fileloader.go | Added logic to detect JS files without allowJs and report TS6504 diagnostic with file inclusion context |
| testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt.diff | Removed diff showing convergence - now properly reports TS6504 for JS files |
| testdata/baselines/reference/submodule/compiler/checkJsFiles6.errors.txt | Added TS6504 error alongside existing TS5052 error |
| testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt.diff | Removed diff showing convergence |
| testdata/baselines/reference/submodule/compiler/jsFileCompilationWithoutJsExtensions.errors.txt | Added TS6504 error for JS file compilation |
| testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt.diff | Removed diff showing convergence for node_modules JS files |
| testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt | Added TS6504 errors for JS files in node_modules |
| testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt.diff | Removed diff for bundler module resolution |
| testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=preserve).errors.txt | Added TS6504 errors for .cjs and .js files |
| testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt.diff | Removed diff for esnext module |
| testdata/baselines/reference/submodule/conformance/bundlerNodeModules1(module=esnext).errors.txt | Added TS6504 errors for bundler with esnext |
| testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt.diff | Removed diff for bundler conditions |
| testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=preserve).errors.txt | Added TS6504 errors for .node.js and .web.js files |
| testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt.diff | Removed diff for esnext with bundler conditions |
| testdata/baselines/reference/submodule/conformance/bundlerConditionsExcludesNode(module=esnext).errors.txt | Added TS6504 errors for conditional JS files |
| testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt.diff | Removed diff for node16 module |
| testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt | Added TS6504 error for exports with node16 |
| testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt.diff | Removed diff for node18 module |
| testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node18).errors.txt | Added TS6504 error for exports with node18 |
| testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt.diff | Removed diff for node20 module |
| testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=node20).errors.txt | Added TS6504 error for exports with node20 |
| testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt.diff | Removed diff for nodenext module |
| testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt | Added TS6504 error for exports with nodenext |
| testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt.diff | Removed diff for bundler module resolution |
| testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt | Added TS6504 errors for multiple JS files with bundler resolution |
| testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt.diff | Removed diff for node16 module resolution |
| testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt | Added TS6504 errors for multiple JS files with node16 resolution |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
tsgowas silently ignoring JavaScript files whenallowJswas not enabled, whiletscreports error TS6504. This madetsgoless helpful for users accidentally compiling.jsfiles.Changes
Modified
internal/compiler/fileloader.go:addRootTaskwhen a root file has a JS extension butallowJsis not enabledprocessingDiagnosticKindExplainingFileIncludeinfrastructure to report the error with file inclusion contextTest baselines updated to match TypeScript compiler output.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
centralus-2.in.applicationinsights.azure.comgo build -tags=noembed,release -o ./built/local/ ./cmd/tsgo(dns block)go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 custom(dns block)go build -ldflags -s -w -X 'main.version=v2.6.0-custom-gcl-94jqzDflNoq1ZZ2lGqIGB8QB8Hs6XG3sDaDhRRIDkMc' -X 'main.date=2025-11-15 19:42:41.252383861 +0000 UTC' -o custom-gcl ./cmd/golangci-lint(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.