Skip to content

Fix moduleResolution -> customConditions test to actually apply both conditions - #64522

Open
auvred wants to merge 1 commit into
microsoft:mainfrom
auvred:fix-custom-conditions-moduleresolution-test
Open

auvred wants to merge 1 commit into
microsoft:mainfrom
auvred:fix-custom-conditions-moduleresolution-test

Conversation

@auvred

@auvred auvred commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

webpack, browser string is splitted by ,

values := strings.Split(value, ",")

and later isn't trimmed

val, err := validateJsonOptionValue(opt.Elements(), v, nil, nil)

However, enum options, like lib are trimmed

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


Other string-list options are passed without spaces (https://github.com/search?q=repo%3Amicrosoft%2FTypeScript+path%3A%2F%5Etsc%5C%2Ftestdata%5C%2Ftests%5C%2Fcases%5C%2F%2F+%2F%5C%2F%5C%2F%5Cs*%40%28types%7CtypeRoots%29.*%2C.*%2F&type=code) so I thought this is the intended way, and this is enough to fix this on test-case level


Aside:

> tsc --noEmit --showConfig --customConditions 'webpack, browser' --lib 'es2015, dom'            
{
    "compilerOptions": {
        "customConditions": [
            "webpack",
            " browser"
        ],
        "lib": [
            "es6",
            "dom"
        ],
        "noEmit": true
    },
    "files": [
        "./index.ts"
    ]
}

See how --lib trims space and correctly produces ["es6", "dom"] while --customConditions has ["webpack", " browser"]. Should I open a separate issue for this?

Copilot AI balanced review requested due to automatic review settings September 29, 2026 08:13
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 29, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

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

🟢 Approval recommended

The updated baselines consistently verify both conditions and the expected resolution behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Corrects the custom conditions conformance test so both conditions are applied.

Changes:

  • Removes whitespace from the comma-separated directive.
  • Updates resolution traces and inferred type baselines.
File Description
customConditions.ts Corrects the test directive.
customConditions(resolvepackagejsonexports=true).types Expects the browser export type.
customConditions(resolvepackagejsonexports=true).trace.json Records browser-condition resolution.
customConditions(resolvepackagejsonexports=false).trace.json Records both parsed conditions.

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

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.

2 participants