Skip to content

Commit 240c9f9

Browse files
committed
chore: fix type check
1 parent 58f3c96 commit 240c9f9

File tree

6 files changed

+21
-11
lines changed

6 files changed

+21
-11
lines changed

packages/devtools-ui-kit/src/components/NDarkToggle.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const isDark = computed<boolean>({
1616
})
1717
1818
const isAppearanceTransition = typeof document !== 'undefined'
19+
// @ts-expect-error document.startViewTransition can be undefined
1920
&& document.startViewTransition
2021
&& !window.matchMedia('(prefers-reduced-motion: reduce)').matches
2122
@@ -35,7 +36,6 @@ function toggle(event?: MouseEvent) {
3536
Math.max(x, innerWidth - x),
3637
Math.max(y, innerHeight - y),
3738
)
38-
// @ts-expect-error: Transition API
3939
const transition = document.startViewTransition(async () => {
4040
isDark.value = !isDark.value
4141
await nextTick()

packages/devtools/client/components/BuildAnalyzeDetails.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { formatTimeAgo } from '@vueuse/core'
55
import { computed, ref } from 'vue'
66
import { ensureDevAuthToken } from '~/composables/dev-auth'
77
import { rpc } from '~/composables/rpc'
8-
import { formatDuration } from '~/composables/utils'
98
109
const props = defineProps<{
1110
current: AnalyzeBuildMeta
@@ -31,6 +30,10 @@ const tabs = computed(() => {
3130
3231
const selectedTab = ref(tabs.value[0])
3332
33+
function getDuration(build: AnalyzeBuildMeta) {
34+
return `${((build.endTime - build.startTime) / 1000).toFixed(1)}s`
35+
}
36+
3437
function formatFileSize(bytes: number) {
3538
if (bytes < 1024)
3639
return `${bytes}B`
@@ -81,7 +84,7 @@ async function clear(name: string) {
8184
<div text-sm op50>
8285
Build duration
8386
</div>
84-
<div>{{ formatDuration(current) }}</div>
87+
<div>{{ getDuration(current) }}</div>
8588
</div>
8689
<template v-if="current.size?.clientBundle">
8790
<div i-carbon-cics-program text-xl />

packages/devtools/client/components/DataSchemaDrawer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const language = computed(() => languages.find(l => l.displayName === selectedLa
1717
// TODO: use localStorage
1818
const options = ref(language.value?.optionDefinitions.filter(o => typeof o.defaultValue === 'boolean'))
1919
20-
const generatedJson = computedAsync(async () => {
20+
const generatedJson = computedAsync<string>(async () => {
2121
// eslint-disable-next-line ts/no-unused-expressions
2222
counter.value
2323
@@ -70,7 +70,7 @@ watch(selectedLang, () => {
7070
const copy = useCopy()
7171
7272
function copyToClipboard() {
73-
copy(generatedJson.value)
73+
copy(generatedJson.value || '')
7474
}
7575
</script>
7676

packages/devtools/client/components/StateEditor.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2-
import type { useVModel, watchPausable } from '@vueuse/core'
2+
import type { watchPausable } from '@vueuse/core'
3+
import { useVModel } from '@vueuse/core'
34
import JsonEditorVue from 'json-editor-vue'
4-
import { nextTick, onMounted, readonly, shallowRef, watch } from 'vue'
5+
import { nextTick, onMounted, shallowRef, watch } from 'vue'
56
import { getColorMode } from '~/composables/client'
67
78
const props = defineProps<{
@@ -116,7 +117,7 @@ async function refresh() {
116117
:main-menu-bar="false"
117118
:navigation-bar="false"
118119
:status-bar="false"
119-
:read-only="readonly"
120+
:read-only="props.readonly"
120121
:indentation="2"
121122
:tab-size="2"
122123
/>

packages/devtools/client/composables/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export function getSocialPreviewCard(
117117
}
118118
}
119119

120-
export function formatDuration(ms: number) {
120+
export function formatDuration(ms: number | string) {
121+
ms = Number(ms)
121122
if (Number.isNaN(ms) || ms < 0)
122123
return '-'
123124
if (ms < 1)

packages/devtools/client/pages/modules/analyze-build.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import type { AnalyzeBuildMeta } from '~/../src/types'
23
import { useRouter } from '#app/composables/router'
34
import { definePageMeta } from '#imports'
45
import { createTemplatePromise, formatTimeAgo } from '@vueuse/core'
@@ -11,7 +12,7 @@ import { registerCommands } from '~/composables/state-commands'
1112
import { useCurrentTerminalId } from '~/composables/state-routes'
1213
import { processAnalyzeBuildInfo } from '~/composables/state-subprocess'
1314
import { telemetry } from '~/composables/telemetry'
14-
import { formatDuration, useSessionState } from '~/composables/utils'
15+
import { useSessionState } from '~/composables/utils'
1516
1617
definePageMeta({
1718
icon: 'carbon-edge-node',
@@ -53,6 +54,10 @@ async function start() {
5354
5455
const terminalId = useCurrentTerminalId()
5556
57+
function getDuration(build: AnalyzeBuildMeta) {
58+
return `${((build.endTime - build.startTime) / 1000).toFixed(1)}s`
59+
}
60+
5661
function gotoTerminal() {
5762
if (processAnalyzeBuildInfo.value?.processId) {
5863
terminalId.value = processAnalyzeBuildInfo.value.processId
@@ -83,7 +88,7 @@ registerCommands(() => [
8388
<code>{{ build.name }}</code>
8489
<div flex="~ gap-1 items-center wrap" w-full text-sm op60>
8590
<div i-carbon-time />
86-
<span>{{ formatDuration(build) }}</span>
91+
<span>{{ getDuration(build) }}</span>
8792
<div flex-auto />
8893
<span>{{ formatTimeAgo(new Date(build.endTime)) }}</span>
8994
</div>

0 commit comments

Comments
 (0)