Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

non-resolvable conditional type assignment causes error #42321

Copy link
Copy link
@Shayan-To

Description

@Shayan-To
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdAn existing issue was already created

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.