Skip to content

true extends false #28654

Closed
Closed
@AnyhowStep

Description

@AnyhowStep

TypeScript Version: 3.2.0-dev.20181117

EDIT: I just tested with TS 3.2.0-rc and it has this bug

Search Terms: true extends false

Code

I feel like I'm losing my mind here. Or maybe I'm tired because it's 3.34am. Maybe I need to take a break. Am I missing something obvious?

//OK
//Expected: "n"
//Actual: "n"
type no = true extends false ? "y" : "n";

type G<DataT extends { b : boolean }> = (
    true extends DataT["b"]?
    ["Actual", "true extends", DataT["b"]] :
    "Expected"
)

//Wat?
//Expected: "Expected"
//Actual: ["Actual", "true extends", false]
type g = G<{ b : false }>;

Expected behavior:

g to be of type "Expected".

Intuitively,

  1. DataT is of type { b : false }
  2. DataT["b"] is of type false
  3. true extends false should be... false

Actual behavior:

g is of type ["Actual", "true extends", false]

Playground Link: Here


EDIT: I just tested and this is not a problem in TS 3.0.1

I'm not crazy, phew.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Indexed Access TypesThe issue relates to accessing subtypes via index accessFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions