Typescript Numeric Literal Types How To X + Y (Addition)

type CreateArrayWithLengthX<
LENGTH extends number,
ACC extends unknown[] = [],
> = ACC['length'] extends LENGTH
? ACC
: CreateArrayWithLengthX<LENGTH, [...ACC,1]>
type AddTwoNumber<T extends number, U extends number> = [...CreateArrayWithLengthX<T>,...CreateArrayWithLengthX<U>]['length']type A = AddTwoNumber<999,999> //1998

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Acid Coder

Acid Coder

Typescript Zombie. Youtube Pikachu On Acid.