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

Nested conditional type with generic tuple argument always expands to false branch. #30708

Copy link
Copy link
@Veetaha

Description

@Veetaha
Issue body actions

TypeScript Version: next (3.4.0-dev.20190330), latest (3.4.1)

Search Terms:

  • tuple conditional type
  • tuple compare
  • tuple comparison

Code

type Not<T extends boolean> = [T] extends [true] ? false : true;
type NoOp<T extends boolean> = Not<Not<T>>; // always expands true (see intellisense)

type t0 = Not<Not<false>>; // false
type t1 = NoOp<false>;     // true (but should be false)

Expected behavior:
Type t1 must be false and NoOp must be of the nested conditional type that depends on T, but not of simple true unit type.
Actual behavior:
As you see, something is broken when you use generic argument for tuple comparison in conditional type, because when you expand your types manually (t0 is an expanded representation of t1) it works as expected.

Playground Link:

Klick me

Related Issues:

This bug report originated from my stackoverflow question.

Additional credits to @dragomirtitian and @fictitious for helping and localizing the bug to a minimal representation.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScriptDomain: Conditional TypesThe issue relates to conditional typesThe issue relates to conditional types

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    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.