Fix inferred project JavaScript file support when compiler options are provided#2622
Draft
Fix inferred project JavaScript file support when compiler options are provided#2622
Conversation
Issue: Fourslash tests were failing when making requests to .js files without explicit @allowJs or @checkjs compiler options. Root cause: The NewInferredProject function was not applying the default AllowJs: true setting when compiler options were explicitly provided (even if AllowJs was not set). Solution: Apply the AllowJs default when compilerOptions is non-nil but AllowJs is TSUnknown. This ensures JavaScript files are always supported in the inferred project, which matches the intended behavior and TypeScript's language server. Test: Added test_js_file_issue_test.go with two tests demonstrating the issue and verifying the fix.
Copilot
AI
changed the title
[WIP] Fix Fourslash error for requests in unconfigured .js files
Fix inferred project JavaScript file support when compiler options are provided
Jan 30, 2026
jakebailey
reviewed
Jan 30, 2026
Comment on lines
+124
to
+128
| } else { | ||
| // Apply inferred project defaults for options that are not explicitly set | ||
| if compilerOptions.AllowJs == core.TSUnknown { | ||
| compilerOptions.AllowJs = core.TSTrue | ||
| } |
Member
There was a problem hiding this comment.
This seems vaguely right given InferredProject has:
override setCompilerOptions(options?: CompilerOptions): void {
// Avoid manipulating the given options directly
if (!options && !this.getCompilationSettings()) {
return;
}
const newOptions = cloneCompilerOptions(options || this.getCompilationSettings());
if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") {
newOptions.maxNodeModuleJsDepth = 2;
}
else if (!this._isJsInferredProject) {
newOptions.maxNodeModuleJsDepth = undefined;
}
newOptions.allowJs = true;
super.setCompilerOptions(newOptions);
}But, mutating the input seems suspect
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fourslash tests failed for .js files when compiler options were provided to the inferred project without explicitly setting
AllowJs. The inferred project only applied itsAllowJs: truedefault whencompilerOptions == nil, causing .js files to be excluded from the project.Changes
Fix in
internal/project/project.go:Now applies
AllowJs: truedefault when the option is unset (TSUnknown), regardless of whethercompilerOptionsis nil.Test coverage in
internal/fourslash/tests/test_js_file_issue_test.go:.jsfiles with no JS-related compiler options (reproduces bug, verifies fix).jsfiles with@checkJs: true(ensures existing behavior preserved).jsfiles with explicit@allowJs: false(ensures explicit settings override defaults)Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.