-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolution
Milestone
Description
TypeScript Version: v3.9.0-dev.20200222
Search Terms: union type object property
Code
type Test =
| { b: [false, "a"] }
| { b: [true, "b"] }
declare const b2: boolean;
const a: Test = { b: b2 ? [b2, "b"] : [b2, "a"] }Expected behavior:
No error. I'm not exactly sure if this is a bug or feature request but, essentially, it'd be nice if TS could recognize that: { b: [true, "b"] | [false, "a"]; } is identical to { b: [true, "b"] } | { b: [false, "a"]; }
Actual behavior:
Type '{ b: [true, "b"] | [false, "a"]; }' is not assignable to type 'Test'.
Type '{ b: [true, "b"] | [false, "a"]; }' is not assignable to type '{ b: [true, "b"]; }'.
Types of property 'b' are incompatible.
Type '[true, "b"] | [false, "a"]' is not assignable to type '[true, "b"]'.
Type '[false, "a"]' is not assignable to type '[true, "b"]'.
Type 'false' is not assignable to type 'true'.
Playground Link: Playground Link
jcalz and boehm-s
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolution