Remove extra params to type detection

This commit is contained in:
Jaco Greeff
2021-08-06 14:56:03 +03:00
parent 54bb965537
commit c51f3d5d2a
2 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ const oo4 = registry.createType<AccountId>('Option<u32>');
const oo5 = registry.createType<IOption<u32>>('u32');
const oo6 = registry.createType<Option<Compact<u32>>>('u32');
const oo7 = registry.createType<Bytes>('u64');
const oo8 = registry.createType<ITuple<[Bytes, u32]>>('Something');
const oo8 = registry.createType<ITuple<[Bytes, u32]>>('(u32)');
assert(oo0.divn(123) && [...oo1.values()] && oo2[6].isAscii && oo3.divn(3) && oo4.isAscii && oo5.unwrap().divn(1) && oo6.unwrap().unwrap().divn(1) && oo7.isAscii && oo8[1].toNumber(), 'All ok');
+6 -6
View File
@@ -39,17 +39,17 @@ export type __Params<X extends string> =
? [__Expand<A>, ...__Params<B>]
: [__Expand<X>];
export type __Tuple<X extends string, T extends Codec> =
export type __Tuple<X extends string> =
// eslint-disable-next-line @typescript-eslint/no-unused-vars
X extends `${infer A},${infer B}`
? ITuple<__Params<X>>
: __Expand<X, T>;
: __Expand<X>;
// vec support with short-circuit for u8
export type __Vec<X extends string, T extends Codec> =
export type __Vec<X extends string> =
Trim<X> extends 'u8'
? Bytes
: Vec<__Expand<X, T>>;
: Vec<__Expand<X>>;
// fixed vec support
export type __VecFixed<X extends string> =
@@ -66,9 +66,9 @@ export type __Unwrap<K extends string, T extends Codec> =
: K extends `Option<${infer X}>`
? Option<__Expand<X>>
: K extends `Vec<${infer X}>`
? __Vec<X, T>
? __Vec<X>
: K extends `[${infer X}]`
? __VecFixed<X>
: K extends `(${infer X})`
? __Tuple<X, T>
? __Tuple<X>
: T;