Skip to content

Nested conditional types make extends clause infer types not visible #22359

Closed
@weswigham

Description

@weswigham

TypeScript Version: 2.7.0-dev.201xxxxx

Code

type Cond<TIn> = TIn extends (infer A extends infer TInside ? infer C : infer D) ? [A, C, D] : never;
// more motivating real example:
type InvertCond<TIn> = TIn extends (infer T extends infer U ? infer A : infer B) ? (T extends U ? B : A) : TIn;

Expected behavior:
At least infer types A, C, and D should be visible within the true branch of the outer conditional type. Arguably, so should TInside, depending on how you expect scoping to work.

Actual behavior:
Cannot find name "A"
Cannot find name "C"
Cannot find name "D"

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions