Skip to content

Trim whitespaces in comma+space separated string-list CLI option values - #64619

Open
auvred wants to merge 1 commit into
microsoft:mainfrom
auvred:string-list-cli-options-trim-whitespace
Open

auvred wants to merge 1 commit into
microsoft:mainfrom
auvred:string-list-cli-options-trim-whitespace

Conversation

@auvred

@auvred auvred commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #64618

Now it matches

val, err := convertJsonOptionOfEnumType(opt.Elements(), strings.TrimFunc(v, stringutil.IsWhiteSpaceLike), nil, nil)

Copilot AI balanced review requested due to automatic review settings October 3, 2026 08:42
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 3, 2026

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.

Copilot review overview

🟡 Changes recommended

Values whose entries all trim to empty can be incorrectly treated as input filenames.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Addresses #64618 by trimming whitespace from comma-separated string-list CLI values, matching enum-list parsing.

Changes:

  • Trim each string-list entry before validation.
  • Add regression coverage for four compiler options.
File Description
tsc/​internal/​tsoptions/​commandlineparser.go Trim whitespace from string-list entries.
tsc/​internal/​tsoptions/​commandlineparser_test.go Test trimming and resolved option values.

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

case "string":
elements := core.MapFiltered(values, func(v string) (any, bool) {
val, err := validateJsonOptionValue(opt.Elements(), v, nil, nil)
val, err := validateJsonOptionValue(opt.Elements(), strings.TrimFunc(v, stringutil.IsWhiteSpaceLike), nil, nil)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a separate issue. --lib also suffers from this:

> npx tsc --showConfig --lib ", ," index.ts 
{
    "compilerOptions": {},
    "files": [
        "./, ,",
        "./index.ts"
    ]
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmed

2 participants