TypeScript

TypeScript 中文群 

u-agfgb 10 hours ago
但是,这个实现代码少啊
u-agfgb 10 hours ago
只需要理解一个 Succ 和 Prev
u-agfgb 10 hours ago
就可以写了
u-aa 10 hours ago
"unknown: namespace arithmetic { type Equal = [A] extends [B] ? ([B] extends [A] ? true : false) : false; type If<Cond, A, B> = Equal<Cond, true> extends true ? A : B; type Nat = Array<undefined>; type Zero = []; type Succ<T extends Nat> = [undefined, ...T]; // prettier-ignore type Prev<T extends Nat> = T extends [undefined, ...infer p] ? p : Zero; type Plus = { a_is_zero: B; a_is_not_zero: Plus<Prev, Succ<B>>; }[A extends Zero ? 'a_is_zero' : 'a_is_not_zero']; type Plus_v2 = A extends Nat ? B extends Nat ? Plus : never : never; type NatToNumber<T extends Nat> = T['length']; type NumberToNatHelper<T extends number, N extends Nat> = { equal: N; not_equal: NumberToNatHelper<T, Succ<N>>; }[If<Equal<N['length'], T>, 'equal', 'not_equal'>]; type NumberToNat<T extends number> = NumberToNatHelper<T, Zero>; // @ts-expect-error Type instantiation is excessively deep and possibly infinite. export type add = NatToNumber< Plus_v2<NumberToNat, NumberToNat<b>> >; } type eleven = arithmetic.add<5, 6>;" - - - - - - - - - - - - - - - 这么就是ts吗 害怕😱
u-agfgb 10 hours ago
> 说到用类型实现数字计算,一大堆邱奇数就冒出来了,但是因为这个限制,这种方法通常只能用于很小的数字
u-aa 10 hours ago
面向类型编程?
u-cc 10 hours ago
2016年架构
u-aa 10 hours ago
继续 @胖胖 
u-cc 10 hours ago
sqlserver忠实用户
u-aa 10 hours ago
开发的人厉害