Remove as unknown (#1636)
* Remove some as unknowns * Rename sanitize * Remove file
This commit is contained in:
committed by
Jaco Greeff
parent
b7ba654e48
commit
f78bf9dde1
@@ -39,7 +39,7 @@ function extractDef (registry: Registry, _def: Record<string, InterfaceTypes | C
|
||||
def[key] = Null;
|
||||
|
||||
return def;
|
||||
}, {} as unknown as TypesDef),
|
||||
}, {} as TypesDef),
|
||||
isBasic: true
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class Struct<
|
||||
|
||||
protected _Types: ConstructorDef;
|
||||
|
||||
constructor (registry: Registry, Types: S, value: V | Map<any, any> | any[] | string = {} as unknown as V, jsonMap: Map<keyof S, string> = new Map()) {
|
||||
constructor (registry: Registry, Types: S, value: V | Map<any, any> | any[] | string = {} as V, jsonMap: Map<keyof S, string> = new Map()) {
|
||||
const Clazzes = mapToTypeMap(registry, Types);
|
||||
const decoded: T = Struct.decodeStruct(registry, Clazzes, value, jsonMap);
|
||||
|
||||
@@ -75,9 +75,9 @@ export default class Struct<
|
||||
(raw as any)[key] = values[index];
|
||||
|
||||
return raw;
|
||||
}, {} as unknown as T);
|
||||
}, {} as T);
|
||||
} else if (!value) {
|
||||
return {} as unknown as T;
|
||||
return {} as T;
|
||||
}
|
||||
|
||||
// We assume from here that value is a JS object (Array, Map, Object)
|
||||
@@ -114,7 +114,7 @@ export default class Struct<
|
||||
}
|
||||
|
||||
return raw;
|
||||
}, {} as unknown as T);
|
||||
}, {} as T);
|
||||
}
|
||||
|
||||
public static with<S extends TypesDef> (Types: S): Constructor<Struct<S>> {
|
||||
@@ -162,7 +162,7 @@ export default class Struct<
|
||||
(result as any)[key] = new Type(this.registry).toRawType();
|
||||
|
||||
return result;
|
||||
}, {} as unknown as E);
|
||||
}, {} as E);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +240,7 @@ export default class Struct<
|
||||
result[key] = new Type(registry).toRawType();
|
||||
|
||||
return result;
|
||||
}, {} as unknown as Record<string, string>);
|
||||
}, {} as Record<string, string>);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,7 +73,7 @@ function _decodeFixedVec (value: TypeDef, type: string, _: string): TypeDef {
|
||||
// as a first round, only u8 via u8aFixed, we can add more support
|
||||
assert(vecLen <= 256, `${type}: Only support for [Type; <length>], where length <= 256`);
|
||||
|
||||
value.ext = { length: vecLen, type: vecType } as unknown as TypeDefExtVecFixed;
|
||||
value.ext = { length: vecLen, type: vecType } as TypeDefExtVecFixed;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ function _removeWrap (_check: string): Mapper {
|
||||
};
|
||||
}
|
||||
|
||||
export default function santize (value: string): string {
|
||||
export default function sanitize (value: string): string {
|
||||
return mappings.reduce((result, fn): string => {
|
||||
return fn(result);
|
||||
}, value).trim();
|
||||
|
||||
@@ -129,7 +129,7 @@ export default class Call extends Struct implements IMethod {
|
||||
result[name.toString()] = Type;
|
||||
|
||||
return result;
|
||||
}, {} as unknown as ArgsDef);
|
||||
}, {} as ArgsDef);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user