From e88c1d5f2c369e19b60af1f1d6424de74020dd2f Mon Sep 17 00:00:00 2001 From: Corentin Thomasset Date: Sun, 23 Apr 2023 16:12:11 +0200 Subject: [PATCH] fix(ts): cleaned legacy typechecking warning --- .github/workflows/ci.yml | 3 +++ src/components/SearchBar.vue | 2 +- src/composable/copy.ts | 6 +++--- src/composable/queryParams.ts | 2 +- src/tools/json-viewer/json.models.ts | 2 +- .../user-agent-parser.types.ts | 2 +- .../user-agent-parser/user-agent-parser.vue | 20 +++++++++---------- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f251edd3..5f5a9b6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,5 +27,8 @@ jobs: - name: Run unit test run: pnpm test + - name: Type check + run: pnpm typecheck + - name: Build the app run: pnpm build diff --git a/src/components/SearchBar.vue b/src/components/SearchBar.vue index 78d6fd7c..e69d8173 100644 --- a/src/components/SearchBar.vue +++ b/src/components/SearchBar.vue @@ -81,7 +81,7 @@ function onFocus() { ; text?: string }) { - const { copy } = useClipboard({ source }); +export function useCopy({ source, text = 'Copied to the clipboard' }: { source: MaybeRef; text?: string }) { + const { copy } = useClipboard({ source: computed(() => String(get(source))) }); const message = useMessage(); return { diff --git a/src/composable/queryParams.ts b/src/composable/queryParams.ts index b62c8b39..9699abbc 100644 --- a/src/composable/queryParams.ts +++ b/src/composable/queryParams.ts @@ -26,7 +26,7 @@ function useQueryParam({ name, defaultValue }: { name: string; defaultValue: return computed({ get() { - return transformer.fromQuery(proxy.value) as T; + return transformer.fromQuery(proxy.value) as unknown as T; }, set(value) { proxy.value = transformer.toQuery(value as never); diff --git a/src/tools/json-viewer/json.models.ts b/src/tools/json-viewer/json.models.ts index 15f981f7..10cd3262 100644 --- a/src/tools/json-viewer/json.models.ts +++ b/src/tools/json-viewer/json.models.ts @@ -9,7 +9,7 @@ function sortObjectKeys(obj: T): T { } if (Array.isArray(obj)) { - return obj.map(sortObjectKeys) as T; + return obj.map(sortObjectKeys) as unknown as T; } return Object.keys(obj) diff --git a/src/tools/user-agent-parser/user-agent-parser.types.ts b/src/tools/user-agent-parser/user-agent-parser.types.ts index f84719fc..6c2720b1 100644 --- a/src/tools/user-agent-parser/user-agent-parser.types.ts +++ b/src/tools/user-agent-parser/user-agent-parser.types.ts @@ -6,7 +6,7 @@ export type UserAgentResultSection = { icon?: Component; content: { label: string; - getValue: (blocks: UAParser.IResult) => string | undefined; + getValue: (blocks?: UAParser.IResult) => string | undefined; undefinedFallback?: string; }[]; }; diff --git a/src/tools/user-agent-parser/user-agent-parser.vue b/src/tools/user-agent-parser/user-agent-parser.vue index a256ec6a..8a3435dd 100644 --- a/src/tools/user-agent-parser/user-agent-parser.vue +++ b/src/tools/user-agent-parser/user-agent-parser.vue @@ -40,12 +40,12 @@ const sections: UserAgentResultSection[] = [ content: [ { label: 'Name', - getValue: (block) => block.browser.name, + getValue: (block) => block?.browser.name, undefinedFallback: 'No browser name available', }, { label: 'Version', - getValue: (block) => block.browser.version, + getValue: (block) => block?.browser.version, undefinedFallback: 'No browser version available', }, ], @@ -56,12 +56,12 @@ const sections: UserAgentResultSection[] = [ content: [ { label: 'Name', - getValue: (block) => block.engine.name, + getValue: (block) => block?.engine.name, undefinedFallback: 'No engine name available', }, { label: 'Version', - getValue: (block) => block.engine.version, + getValue: (block) => block?.engine.version, undefinedFallback: 'No engine version available', }, ], @@ -72,12 +72,12 @@ const sections: UserAgentResultSection[] = [ content: [ { label: 'Name', - getValue: (block) => block.os.name, + getValue: (block) => block?.os.name, undefinedFallback: 'No OS name available', }, { label: 'Version', - getValue: (block) => block.os.version, + getValue: (block) => block?.os.version, undefinedFallback: 'No OS version available', }, ], @@ -88,17 +88,17 @@ const sections: UserAgentResultSection[] = [ content: [ { label: 'Model', - getValue: (block) => block.device.model, + getValue: (block) => block?.device.model, undefinedFallback: 'No device model available', }, { label: 'Type', - getValue: (block) => block.device.type, + getValue: (block) => block?.device.type, undefinedFallback: 'No device type available', }, { label: 'Vendor', - getValue: (block) => block.device.vendor, + getValue: (block) => block?.device.vendor, undefinedFallback: 'No device vendor available', }, ], @@ -109,7 +109,7 @@ const sections: UserAgentResultSection[] = [ content: [ { label: 'Architecture', - getValue: (block) => block.cpu.architecture, + getValue: (block) => block?.cpu.architecture, undefinedFallback: 'No CPU architecture available', }, ],