any
type JS-0323 45 loggedIn: useStorageAsync("loggedIn", s.loggedIn, idbStore),
46 user: useStorageAsync("user", s.user, idbStore, {
47 serializer: {
48 read: (v: any) => new User(JSON.parse(v)), 49 write: (v: User) => JSON.stringify(v),
50 },
51 }),
148export async function getKeys(
149 password: string,
150 saltEncoded: string
151): Promise<{ authKey: string; pgpPassphrase: string; err: NullError<any> }> {152 const salt = parse(saltEncoded);
153 salt.cost.FillEmpty();
154
93export async function genKeys(
94 username: string,
95 password: string
96): Promise<{ userKey: userKey; recoveryKey: string; err: NullError<any> }> { 97 const recoveryKey = create();
98
99 const recoveryKeyArray = exportKey((await recoveryKey).key);
51 saltEncoded: string;
52 authKey: string;
53 pgpPassphrase: string;
54 err: NullError<any>; 55}> {
56 // Hash password
57 const { hash, err } = await hashA2(
10
11interface hashReturn {
12 encodedHash: string;
13 err: NullError<any>;14}
15
16async function hash(
The any
type can sometimes leak into your codebase. TypeScript compiler skips the type checking of the any
typed variables, so it creates a potential safety hole, and source of bugs in your codebase. We recommend using unknown
or never
type variable.
In TypeScript, every type is assignable to any
. This makes any
a top type (also known as a universal supertype) of the type system.
The any
type is essentially an escape hatch from the type system. As developers, this gives us a ton of freedom: TypeScript lets us perform any operation we want on values of type any
without having to perform any checking beforehand.
The developers should not assign any
typed value to variables and properties, which can be hard to pick up on, especially from the external library; instead, developers can use the never
or unknown
type variable.
const age: any = 'seventeen';
const ages: any[] = ['seventeen'];
const ages: Array<any> = ['seventeen'];
function greet(): any {}
function greet(): any[] {}
function greet(): Array<any> {}
function greet(): Array<Array<any>> {}
function greet(param: Array<any>): string {}
function greet(param: Array<any>): Array<any> {}
const age: number = 17;
const ages: number[] = [17];
const ages: Array<number> = [17];
function greet(): string {}
function greet(): string[] {}
function greet(): Array<string> {}
function greet(): Array<Array<string>> {}
function greet(param: Array<string>): string {}
function greet(param: Array<string>): Array<string> {}