How to ‘map’ a Tuple to another Tuple type in Typescript 3.0

You’ll need to use a mapped tuple type, which is supported in TypeScript 3.1. You can make a mapped type that has properties 0, 1, 2 and length of the correct types, like this: class Maybe<T> {} type MaybeTuple = [Maybe<string>, Maybe<number>, Maybe<boolean>]; type MaybeType<T> = T extends Maybe<infer MaybeType> ? MaybeType : never; type … Read more

‘unknown’ vs. ‘any’

You can read more about unknown in the PR or the RC announcement, but the gist of it is: [..] unknown which is the type-safe counterpart of any. Anything is assignable to unknown, but unknown isn’t assignable to anything but itself and any without a type assertion or a control flow based narrowing. Likewise, no … Read more