Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

fixes #61076

@Andarist
Copy link
Contributor Author

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

@jakebailey
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
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

@@ -20422,6 +20422,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
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
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
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/[email protected]".;

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

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