Skip to content

Commit 1c1a350

Browse files
committed
fix types and error
1 parent dedd8e8 commit 1c1a350

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

packages/linejs/client/clients/e2ee/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class E2EE extends TalkClient {
3535
try {
3636
return JSON.parse(this.storage.get("e2eeKeys:" + keyId) as string);
3737
} catch (_e) {
38-
/* DoNothing */
38+
/* Do Nothing */
3939
}
4040
}
4141
public saveE2EESelfKeyDataByKeyId(keyId: string | number, value: LooseType) {

packages/linejs/client/clients/internal/liff-client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ export class LiffClient extends BaseClient {
8989
lang,
9090
});
9191
return liff[3];
92-
} catch (e) {
93-
this.log("liff-error", { ...e.data });
94-
if (e.data.code === 3 && tryConsent) {
95-
const data: LINETypes.LiffException = e.data;
92+
} catch (error) {
93+
this.log("liff-error", { ...error.data });
94+
if (error.data.code === 3 && tryConsent) {
95+
const data: LINETypes.LiffException = error.data;
9696
const payload = data.payload;
9797
const consentRequired = payload.consentRequired;
9898
const channelId = consentRequired.channelId;

packages/linejs/client/libs/storage/base-storage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import type { LooseType } from "../../entities/common.ts";
2+
13
export interface Storage {
24
Key: string;
3-
Value: string | number | boolean | null | undefined;
5+
Value: string | number | boolean | null | Record<string | number, LooseType>;
46
}
57

68
/**

packages/linejs/client/libs/storage/cache-manager.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { BaseStorage } from "../../../storage/index.ts";
2+
import type { LooseType } from "../../entities/common.ts";
23

34
interface Storage {
45
Key: string;
5-
Value: string | number | boolean | null | Record<string | number, any>;
6+
Value: string | number | boolean | null | Record<string | number, LooseType>;
67
}
78

89
type CacheInfo = Record<Storage["Key"], number>;
@@ -52,7 +53,7 @@ export class CacheManager {
5253
*/
5354
public setCache(
5455
requestName: string,
55-
request: Record<string, any>,
56+
request: Record<string, LooseType>,
5657
response: Storage["Value"],
5758
): void {
5859
this.set(requestName + JSON.stringify(request), response);
@@ -69,7 +70,7 @@ export class CacheManager {
6970
try {
7071
this.cacheInfo[key] = new Date().getTime();
7172
return JSON.parse(this.storage.get("cache:" + key) as string);
72-
} catch (error) {}
73+
} catch (_e) {/* Do Nothing */}
7374
}
7475

7576
/**
@@ -81,7 +82,7 @@ export class CacheManager {
8182
*/
8283
public getCache(
8384
requestName: string,
84-
request: Record<string, any>,
85+
request: Record<string, LooseType>,
8586
): Storage["Value"] | undefined {
8687
return this.get(requestName + JSON.stringify(request));
8788
}

packages/linejs/client/libs/storage/dir-storage.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,20 @@ export class DirStorage extends BaseStorage {
6262
public get(key: Storage["Key"]): Storage["Value"] | undefined {
6363
try {
6464
return this.getValue(fs.readFileSync(this.getPath(key), "utf-8"));
65-
} catch (_error) {}
65+
} catch (_e) {/* Do Nothing */}
6666
}
6767

6868
public delete(key: Storage["Key"]): void {
6969
try {
7070
fs.rmSync(this.getPath(key));
71-
} catch (_e) {}
71+
} catch (_e) {/* Do Nothing */}
7272
}
7373

7474
public clear(): void {
7575
fs.readdirSync(this.path).forEach((e) => {
7676
try {
7777
fs.rmSync(e);
78-
} catch (_e) {}
78+
} catch (_e) {/* Do Nothing */}
7979
});
8080
}
8181

@@ -90,33 +90,27 @@ export class DirStorage extends BaseStorage {
9090
switch (typeof obj) {
9191
case "string":
9292
return "s" + obj.toString();
93-
break;
9493
case "number":
9594
return "n" + obj.toString();
96-
break;
9795
case "boolean":
9896
return "b" + obj.toString();
99-
break;
10097
default:
10198
return "x";
102-
break;
10399
}
104100
}
105101

106102
public getValue(value: string): Storage["Value"] {
107103
switch (value[0]) {
108104
case "s":
109105
return value.substring(1);
110-
break;
111106
case "n":
112107
return Number(value.substring(1));
113-
break;
114108
case "b":
115109
return Boolean(value.substring(1));
116-
break;
117110
case "x":
118111
return null;
119-
break;
112+
default:
113+
return null;
120114
}
121115
}
122116
}

0 commit comments

Comments
 (0)