Skip to content

Instantly share code, notes, and snippets.

@faustienf
Created November 17, 2019 12:47
Show Gist options
  • Save faustienf/d988a4e8a9c58d6bb3a64053a3d107f2 to your computer and use it in GitHub Desktop.
Save faustienf/d988a4e8a9c58d6bb3a64053a3d107f2 to your computer and use it in GitHub Desktop.
// copy from https://github.com/microsoft/TypeScript/issues/13298#issuecomment-513813788
type Overwrite<T, S extends any> = {[P in keyof T]: S[P]};
type TupleUnshift<T extends any[], X> = T extends any ? ((x: X, ...t: T) => void) extends (...t: infer R) => void ? R : never : never;
type TuplePush<T extends any[], X> = T extends any
? Overwrite<TupleUnshift<T, any>, T & {[x: string]: X}>
: never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment