Browse Source

refactor: 代码迁移

es6
iapyang 5 years ago
parent
commit
b42fdd78b8
  1. 25
      typescript/core/decorator/decorator.ts

25
typescript/core/decorator/decorator.ts

@ -59,3 +59,28 @@ export class Model<U extends {types?: {[key: string]: unknown} | {}, context?: R
computed: {[key: string]: () => unknown} | {};
}
/*
// union to intersection of functions
type UnionToIoF<U> =
(U extends any ? (k: (x: U) => void) => void : never) extends
((k: infer I) => void) ? I : never
// return last element from Union
type UnionPop<U> = UnionToIoF<U> extends { (a: infer A): void; } ? A : never;
// prepend an element to a tuple.
type Prepend<U, T extends ReadonlyArray<any>> =
((a: U, ...r: T) => void) extends (...r: infer R) => void ? R : never;
type UnionToTupleRecursively<Union, Result extends ReadonlyArray<any>> = {
1: Result;
0: UnionToTupleRecursively_<Union, UnionPop<Union>, Result>;
// 0: UnionToTupleRecursively<Exclude<Union, UnionPop<Union>>, Prepend<UnionPop<Union>, Result>>
}[[Union] extends [never] ? 1 : 0];
type UnionToTupleRecursively_<Union, Element, Result extends ReadonlyArray<any>> =
UnionToTupleRecursively<Exclude<Union, Element>, Prepend<Element, Result>>;
type UnionToTuple<U> = UnionToTupleRecursively<U, []>;
*/
Loading…
Cancel
Save