Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 10, 2025

  • Add parameter to pass raw command line options through config parsing functions
  • Update mergeCompilerOptions to use raw command line options
  • Update all call sites of ParseJsonSourceFileConfigFilePath
  • Add test for --customConditions null override
  • Run existing tests to ensure no regressions
  • Verify fix works as expected with manual testing
  • Fix nil targetOptions by initializing in parseConfig instead of workaround in mergeCompilerOptions
  • Eliminate WithRaw functions, add raw parameter to existing functions
  • Run formatter
  • Wrap command line options in compilerOptions key to simplify mergeCompilerOptions
  • Add Raw field to ParsedBuildCommandLine for build mode support
Original prompt

This section details on the original issue you should resolve

<issue_title>Passing --customConditions null it not respected</issue_title>
<issue_description>## Steps to reproduce
I don't have a repo, but I can create it if mandatory

Behavior with [email protected]

running tsc --customConditions null overrides the customConditions and sets it to null

Behavior with tsgo

running tsgo --customConditions null does not override customConditions and uses the customConditions from tsconfig.json</issue_description>

Comments on the Issue (you are @copilot in this section)

@jakebailey I'm not sure if the CLI parser supports nulling out flags yet. Seemingly not.

Fixes #1866


💡 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.

Copilot AI and others added 2 commits October 10, 2025 15:24
When --customConditions null is passed on command line, it should override any value in tsconfig.json. This fix:
- Adds a new parameter to pass raw command line options through config parsing
- Updates mergeCompilerOptions to handle command line raw options correctly
- Adds test to verify customConditions null override behavior

Co-authored-by: jakebailey <[email protected]>
- Handle nil OrderedMap in mergeCompilerOptions
- Handle nil targetOptions in mergeCompilerOptions
- Accept baseline for composite null test (correct behavior)

Co-authored-by: jakebailey <[email protected]>
Copilot AI changed the title [WIP] Fix handling of --customConditions flag for null value Fix --customConditions null not being respected when overriding tsconfig.json Oct 10, 2025
Copilot AI requested a review from jakebailey October 10, 2025 15:37
Copilot finished work on behalf of jakebailey October 10, 2025 15:37
Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This PR may be too narrowly focused. null should work to unset all of the other options at the CLI too.

Instead of checking for nil in mergeCompilerOptions, properly initialize
options to empty struct when circularity error is detected in parseConfig.
This ensures targetOptions is never nil when mergeCompilerOptions is called.

Co-authored-by: jakebailey <[email protected]>
Copy link
Contributor Author

Copilot AI commented Oct 10, 2025

@copilot This PR may be too narrowly focused. null should work to unset all of the other options at the CLI too.

The implementation already works for all options, not just customConditions. It uses reflection to iterate through all CompilerOptions fields and checks the raw map for any field set to null. I verified this works with --lib null, --types null, and --outDir null - all correctly override their tsconfig.json values.

Copilot AI requested a review from jakebailey October 10, 2025 16:43
Copilot finished work on behalf of jakebailey October 10, 2025 16:43
Instead of having separate WithRaw variants, add optionsRaw parameter
to GetParsedCommandLineOfConfigFile and ParseJsonSourceFileConfigFileContent.
This simplifies the API by consolidating the two variants into one.

Co-authored-by: jakebailey <[email protected]>
Copilot AI requested a review from jakebailey December 1, 2025 23:18
Copilot finished work on behalf of jakebailey December 1, 2025 23:18
@jakebailey
Copy link
Member

@copilot you did not run the formatter as instructed

Copy link
Contributor Author

Copilot AI commented Dec 2, 2025

@copilot you did not run the formatter as instructed

Fixed in commit 81d4e0d. Ran npx hereby format to correct indentation.

Copilot finished work on behalf of jakebailey December 2, 2025 00:03
Instead of having two code paths in mergeCompilerOptions (one for tsconfig with nested
compilerOptions, one for raw command line options), wrap the command line options in a
compilerOptions key before passing them. This simplifies the logic and prevents accidentally
processing top-level keys from tsconfig as compiler options.

Also removes the options initialization in parseConfig error case, which is no longer needed
with the wrapped approach.

Co-authored-by: jakebailey <[email protected]>
Copilot AI requested a review from jakebailey December 2, 2025 00:33
Copilot finished work on behalf of jakebailey December 2, 2025 00:33
@jakebailey jakebailey marked this pull request as ready for review December 2, 2025 00:36
Copilot AI review requested due to automatic review settings December 2, 2025 00:36
Copilot finished reviewing on behalf of jakebailey December 2, 2025 00:40
Copy link
Contributor

Copilot AI left a 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 fixes the issue where passing --customConditions null on the command line was not properly overriding the customConditions setting from tsconfig.json. The fix enables the command line parser to track explicitly null values and merge them correctly when loading config files.

Key Changes

  • Added existingOptionsRaw parameter to config parsing functions to preserve raw command line options with explicit null values
  • Updated mergeCompilerOptions to detect and apply explicitly null fields from raw command line options by wrapping them in a "compilerOptions" key structure
  • Added test case TestCustomConditionsNullOverride to verify the fix works correctly

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/tsoptions/tsconfigparsing.go Added existingOptionsRaw parameter to ParseJsonSourceFileConfigFileContent, GetParsedCommandLineOfConfigFile, GetParsedCommandLineOfConfigFilePath, and parseJsonConfigFileContentWorker to thread raw command line options through config parsing
internal/tsoptions/parsinghelpers.go Updated mergeCompilerOptions to extract explicitly null fields from raw options (nested under "compilerOptions" key) and apply them to target options
internal/execute/tsc.go Wraps command line raw options in a "compilerOptions" key before passing to config parsing to match tsconfig.json structure
internal/tsoptions/commandlineparser_test.go Added TestCustomConditionsNullOverride test to verify command line null values override tsconfig.json settings
internal/tsoptions/tsconfigparsing_test.go Updated all test call sites to include the new existingOptionsRaw parameter (passing nil)
internal/tsoptions/tsoptionstest/parsedcommandline.go Updated helper function to include the new parameter
internal/testrunner/test_case_parser.go Updated config parsing call to include the new parameter
internal/project/configfileregistrybuilder.go Updated config parsing call to pass nil for optionsRaw
internal/execute/watcher.go Updated config parsing call to pass nil for optionsRaw (watch mode doesn't support raw option overrides)
internal/execute/build/host.go Updated config parsing call to pass nil for optionsRaw
internal/execute/tsctests/tscbuild_test.go Updated test call to include the new parameter
internal/compiler/program_test.go Updated test calls to include the new parameter
internal/compiler/host.go Updated config parsing call to include the new parameter
internal/checker/checker_test.go Updated test calls to include the new parameter
internal/api/api.go Updated config parsing call to include the new parameter
testdata/baselines/reference/tsc/composite/when-setting-composite-null-on-command-line.js Baseline update showing that --composite null correctly suppresses .d.ts and .tsbuildinfo file generation, overriding tsconfig.json

return h.resolvedReferences.loadOrStoreNew(path, func(path tspath.Path) *tsoptions.ParsedCommandLine {
configStart := h.orchestrator.opts.Sys.Now()
commandLine, _ := tsoptions.GetParsedCommandLineOfConfigFilePath(fileName, path, h.orchestrator.opts.Command.CompilerOptions, h, &h.extendedConfigCache)
commandLine, _ := tsoptions.GetParsedCommandLineOfConfigFilePath(fileName, path, h.orchestrator.opts.Command.CompilerOptions, nil /*optionsRaw*/, h, &h.extendedConfigCache)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont you need the "raw" thing here because this is tsc -b which will pass commandline options ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. @copilot 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit b8f9e2a. Added Raw field to ParsedBuildCommandLine and now wrapping and passing raw options in build mode.

For tsc -b (build mode), command line options also need to be passed with their
raw values to properly support null overrides. This adds:
- Raw field to ParsedBuildCommandLine to store raw command line options
- Wrapping of raw options in "compilerOptions" key in build/host.go
- Passing wrapped raw options to GetParsedCommandLineOfConfigFilePath

Co-authored-by: jakebailey <[email protected]>
Copilot finished work on behalf of jakebailey December 2, 2025 18:20
Copilot AI requested a review from jakebailey December 2, 2025 18:20
@jakebailey jakebailey added this pull request to the merge queue Dec 2, 2025
Merged via the queue into main with commit 487416c Dec 3, 2025
42 checks passed
@jakebailey jakebailey deleted the copilot/fix-custom-conditions-null branch December 3, 2025 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passing --customConditions null it not respected

3 participants