Skip to content

Unwrap NoInfer-wrapped unions before conditional type distribution attempt#61077

Closed
Andarist wants to merge 5 commits intomicrosoft:mainfrom
Andarist:fix/unwrap-noinfer-before-distribution
Closed

Unwrap NoInfer-wrapped unions before conditional type distribution attempt#61077
Andarist wants to merge 5 commits intomicrosoft:mainfrom
Andarist:fix/unwrap-noinfer-before-distribution

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

fixes #61076

@Andarist
Copy link
Copy Markdown
Contributor Author

@jakebailey could you prepare a playground build for this one? :p

@jakebailey
Copy link
Copy Markdown
Member

@typescript-bot pack this

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Jan 29, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
const checkType = root.checkType;
let distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : undefined;
if (distributionType && isNoInferType(distributionType)) {
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.

I have 2 doubts here:

  1. This still doesn't solve the issue with A | NoInfer<B | C>. To solve that, it feels like mapTypeWithAlias and mapType should learn how to deal with those NoInfer-wrapped unions
  2. Should the conditional type's result be "repacked" into NoInfer back if needed? 🤔

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Jan 29, 2025

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/164685/artifacts?artifactName=tgz&fileId=8CCB4161634DFD3F5FEB343C0D9567C6F11C57ECCBCE5D313B663902C239CF5802&fileName=/typescript-5.8.0-insiders.20250129.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.8.0-pr-61077-3".;

@Andarist Andarist force-pushed the fix/unwrap-noinfer-before-distribution branch from 0737761 to 892d183 Compare January 30, 2025 11:21
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jan 30, 2025
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 4, 2025
@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

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

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Distributive conditional types can't distribute over NoInfer types wrapping a union

4 participants