Skip to content

Commit a402132

Browse files
committed
types: fix all type errors
1 parent df754c0 commit a402132

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

app/app.vue

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
<script setup lang="ts">
2-
const runs = ref([]);
3-
const error = ref(null);
2+
interface Run {
3+
url: string;
4+
status: number;
5+
cacheHeaders: Record<string, string>;
6+
durationInMs: number;
7+
}
8+
9+
const runs = ref<Run[]>([]);
10+
const error = ref<string | null>(null);
411
5-
const handleRequestFormSubmit = async ({ url }): void => {
12+
const handleRequestFormSubmit = async ({
13+
url,
14+
}: {
15+
url: string;
16+
}): Promise<void> => {
617
try {
718
// Destructuring would be confusing, since the response body contains fields named `status` and
819
// `headers` (it's a request about a request...)
@@ -18,7 +29,9 @@ const handleRequestFormSubmit = async ({ url }): void => {
1829
});
1930
2031
error.value = null;
21-
} catch (err) {
32+
// TODO(serhalp) nuxt doesn't appear to re-export the `FetchError` types from ofetch. Look into
33+
// this.
34+
} catch (err: any) {
2235
error.value =
2336
err?.data?.message ??
2437
err?.toString?.() ??

app/components/CacheAnalysis.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const cacheAnalysis = computed(() =>
3030
getCacheAnalysis(props.cacheHeaders, now.value),
3131
);
3232
33-
let timerId;
33+
let timerId: NodeJS.Timeout | null = null;
3434
3535
onMounted(() => {
3636
timerId = setInterval(() => {

app/components/RawCacheHeaders.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ const props = defineProps<{
33
cacheHeaders: Record<string, string>;
44
}>();
55
6-
const id = useId();
7-
const el = useTemplateRef(id);
6+
const el = useTemplateRef("code-block");
87
const highlightJson = () => {
9-
hljs.highlightElement(el.value);
8+
if (el.value != null) {
9+
hljs.highlightElement(el.value);
10+
}
1011
};
1112
onMounted(highlightJson);
1213
onUpdated(highlightJson);
1314
</script>
1415

1516
<template>
1617
<pre>
17-
<code :ref="id" class="hljs language-json">{{ JSON.stringify(props.cacheHeaders, null, 2) }}</code>
18+
<code ref="code-block" class="hljs language-json">{{ JSON.stringify(props.cacheHeaders, null, 2) }}</code>
1819
</pre>
1920
</template>
2021

global.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare global {
2+
const hljs: {
3+
highlightElement: (element: HTMLElement) => void;
4+
};
5+
}
6+
7+
export { };

0 commit comments

Comments
 (0)