Reproduced with TS 3.4.1 and [email protected].
Search Terms:
Union typed array spreads used to work with TS 3.3 but require explicit types with TS 3.4.
Code
Works as expected on both 3.3 and 3.4:
declare function concat<T>(...args: (T | T[])[]): T[]
concat([1, 2, 3], 4)
Works on 3.3, breaks under 3.4 and @next:
export type Maybe<T> = T | undefined
declare function concatMaybe<T>(...args: (Maybe<T> | Maybe<T>[])[]): T[]
concatMaybe([1, 2, 3], 4)
Unexpected error
error TS2345: Argument of type '4' is not assignable to parameter of type 'number[] | (number[] | undefined)[] | undefined'.
This _does_ compile under 3.4, fwiw:
concatMaybe<number>([1, 2, 3], 4)
Related Issues:
@ahejlsberg I don't know if you and your team get this enough, but THANK YOU FOR TYPESCRIPT!
You and your team are doing great work. Kudos!
@mceachen Thanks, much appreciated!
For real, TypeScript is the closest I have ever felt to expressing thought into code at the speed I can think it.
Most helpful comment
@ahejlsberg I don't know if you and your team get this enough, but THANK YOU FOR TYPESCRIPT!
You and your team are doing great work. Kudos!