Skip to content

Port parseCommandLine, readConfigFile, and parseJsonConfigFileContent - #4888

Merged
John Favret (johnfav03) merged 9 commits into
mainfrom
johnfav03/feature-4830-command-line-api
Aug 13, 2026
Merged

Port parseCommandLine, readConfigFile, and parseJsonConfigFileContent#4888
John Favret (johnfav03) merged 9 commits into
mainfrom
johnfav03/feature-4830-command-line-api

Conversation

@johnfav03

Copy link
Copy Markdown
Contributor

In the TS API, these are exposed as:

  • parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined)
  • readConfigFile(fileName: string, readFile: (path: string) => string | undefined)
  • parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map<string, ExtendedConfigCacheEntry>, existingWatchOptions?: WatchOptions)

Part of #4830

Copilot AI balanced review requested due to automatic review settings August 12, 2026 20:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Ports command-line and JSON config parsing APIs for the native-preview API, advancing #4830.

Changes:

  • Adds parseCommandLine, readConfigFile, and parseJsonConfigFileContent.
  • Adds watch-option, raw-config, and diagnostic serialization.
  • Expands Go and TypeScript API coverage.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-compileOnSave-and-more.js Updates compileOnSave baseline.
internal/tsoptions/tsconfigparsing.go Parses and merges watch options and JSON values.
internal/tsoptions/tsconfigparsing_test.go Tests JSON representations and watch options.
internal/tsoptions/declswatch.go Exposes the watch-option map.
internal/tsoptions/commandlineparser.go Adds API-compatible parsing and response-file safeguards.
internal/tsoptions/commandlineparser_test.go Tests response-file parsing.
internal/api/session.go Handles the new API requests.
internal/api/proto.go Defines request and response protocol structures.
internal/api/proto_test.go Tests ordered JSON decoding.
_packages/native-preview/test/sync/api.test.ts Adds synchronous API integration tests.
_packages/native-preview/test/async/api.test.ts Adds asynchronous API integration tests.
_packages/native-preview/src/api/sync/types.ts Updates generated synchronous types.
_packages/native-preview/src/api/sync/api.ts Exposes synchronous parsing APIs.
_packages/native-preview/src/api/proto.ts Defines client protocol result types.
_packages/native-preview/src/api/async/types.ts Shares diagnostic protocol types.
_packages/native-preview/src/api/async/api.ts Exposes asynchronous parsing APIs.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/tsoptions/tsconfigparsing.go
Comment thread internal/tsoptions/tsconfigparsing.go Outdated
Comment thread internal/tsoptions/tsconfigparsing.go Outdated
Comment thread internal/api/proto.go Outdated
Comment thread internal/api/proto.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Suppressed comments (1)

internal/tsoptions/tsconfigparsing.go:1526

  • This leaves CompileOnSave nil when the property is absent or invalid, so the API omits compileOnSave and clients observe undefined. The reference parseJsonConfigFileContent always returns a boolean using !!raw.compileOnSave (commandLineParser.ts:3106), which is false in these cases. Initialize the result to false and always return its pointer from config parsing.
	var compileOnSave *bool
	if raw, ok := parsedConfig.raw.(*collections.OrderedMap[string, any]); ok {
		if value, ok := raw.GetOrZero("compileOnSave").(bool); ok {
			compileOnSave = &value
		}

Comment thread internal/tsoptions/tsconfigparsing.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Suppressed comments (1)

internal/tsoptions/tsconfigparsing.go:1531

  • The reference parseJsonConfigFileContent always returns a boolean compileOnSave (!!raw.compileOnSave), including false when the property is absent or invalid. Leaving this pointer nil causes the IPC response to omit the field, so callers receive undefined instead of the expected false. Initialize the result to false and overwrite it when a boolean value is present.
	var compileOnSave *bool
	if raw, ok := parsedConfig.raw.(*collections.OrderedMap[string, any]); ok {
		if value, ok := raw.GetOrZero("compileOnSave").(bool); ok {
			compileOnSave = &value
		}

Comment thread internal/tsoptions/tsconfigparsing.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is looking very good!

Comment thread _packages/native-preview/src/api/proto.ts Outdated
Comment thread _packages/native-preview/test/sync/api.test.ts Outdated
Comment thread internal/api/proto.go Outdated
Comment thread internal/tsoptions/commandlineparser.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! Looks like this caught several config parsing bugs along the way. Thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Suppressed comments (1)

internal/tsoptions/tsconfigparsing.go:980

  • parseJsonConfigFileContent is expected to normalize raw.compileOnSave to a boolean even when the property is absent or invalid. The reference implementation always assigns convertCompileOnSaveOptionFromJson(...), whose default/error result is false (_submodules/TypeScript/src/compiler/commandLineParser.ts:3507-3514,3725-3730). This conditional leaves the key absent, or stores nil after a type error, and also lets an omitted value inherit true from an extended JSON config when the reference JSON API does not. Always write the normalized boolean default.
	if compileOnSave, ok := json.Get("compileOnSave"); ok {
		converted, compileOnSaveErrors := convertJsonOption(compileOnSaveCommandLineOption, compileOnSave, basePath, nil, nil, nil)
		errors = append(errors, compileOnSaveErrors...)
		json.Set("compileOnSave", converted)

Comment thread internal/api/session.go
@johnfav03
John Favret (johnfav03) added this pull request to the merge queue Aug 13, 2026
@johnfav03
John Favret (johnfav03) removed this pull request from the merge queue due to a manual request Aug 13, 2026
@johnfav03
John Favret (johnfav03) added this pull request to the merge queue Aug 13, 2026
Merged via the queue into main with commit df11150 Aug 13, 2026
22 checks passed
@johnfav03
John Favret (johnfav03) deleted the johnfav03/feature-4830-command-line-api branch August 13, 2026 18:26
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.

3 participants