Skip to content

non-resolvable conditional type assignment causes error #42321

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

Closed
Shayan-To opened this issue Jan 13, 2021 · 2 comments
Closed

non-resolvable conditional type assignment causes error #42321

Shayan-To opened this issue Jan 13, 2021 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@Shayan-To
Copy link

Shayan-To commented Jan 13, 2021

Bug Report

When in a generic function a conditional type cannot be resolved and is remained as is, nothing can be assigned to it (apparently).

🔎 Search Terms

conditional type assignment

🕗 Version & Regression Information

  • I tested this on version 4.1.2 and nightly. Playground's toolbar was not functioning, so I couldn't check other versions.

⏯ Playground Link

Playground's toolbar was not functioning, so I couldn't check other versions. I reloaded the page a few times and waited for some time, and used different browsers, but it didn't work.

💻 Code

function f<T>() {
    const a: T = null!;
    const b: T extends string ? T : T = a;
}

🙁 Actual behavior

Gives this error: Type 'T' is not assignable to type 'T extends string ? T : T'. (2322)

🙂 Expected behavior

It should check the type of a against the two conditional cases and type-check successfully.

@RyanCavanaugh
Copy link
Member

See #30639

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 13, 2021
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants