-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Bug Report
π Search Terms
Extract
Extract is not pure
Extract behaviour
π Version & Regression Information
v4.5.0-beta
β― Playground Link
Playground link with relevant code
π» Code
type Input = number[] | string[];
type JoinArrays<T> = T extends (infer Element)[] ? Element[] : never;
type JoinArraysWithExtract<T> = Extract<T, T> extends (infer Element)[] ? Element[] : never;
type Output = JoinArrays<Input> // number[] | string[]
type OutputWithExtract = JoinArraysWithExtract<Input> // (string | number)[]
type Wanted = (number | string)[];
π Actual behavior
type Extract<T, U> = T extends U ? T : never
implies that replacing Extract<T, T>
with T
should return exactly the same type.
But replacing it in the example I have provided results in two different types.
π Expected behavior
type JoinArrays<T> = T extends (infer Element)[] ? Element[] : never;
should be the same as
type JoinArraysWithExtract<T> = Extract<T, T> extends (infer Element)[] ? Element[] : never;
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug