Multiply
Challenge
This challenge continues from 476 - Sum, it is recommended that you finish that one first, and modify your code based on it to start this challenge.
Implement a type Multiply<A, B> that multiplies two non-negative integers and returns their product as a string. Numbers can be specified as string, number, or bigint.
For example,
type T0 = Multiply<2, 3>; // '6'
type T1 = Multiply<3, "5">; // '15'
type T2 = Multiply<"4", 10>; // '40'
type T3 = Multiply<0, 16>; // '0'
type T4 = Multiply<"13", "21">; // '273'
type T5 = Multiply<"43423", 321543n>; // '13962361689'
Solution
// Dreht eine Zahl oder eine Zahl als String um
// `1234` => `4321`
// 1234 => `4321`
type Reverse<A extends string | number | bigint> =
`${A}` extends `${infer AH}${infer AT}` ? `${Reverse<AT>}${AH}` : "";
// Erhoeht die Zahl um eins
// 1234 => 2234
// 5 => 6
type AddOne<A> = A extends `${infer AH}${infer AT}`
? AH extends "9"
? `0${AddOne<AT>}`
: `${DigsNext[AH & keyof DigsNext]}${AT}`
: "1";