Skip to content

Commit b962272

Browse files
committed
🏷️ Properly type some things
1 parent a8ab7d3 commit b962272

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

packages/docs/src/lib/components/CopyButton.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
77
const copy = async (text: string): Promise<string | null> => {
88
if (browser) {
9-
return await navigator.clipboard
9+
const clipboardResult = await navigator.clipboard
1010
?.writeText(text)
1111
.then(() => {
1212
return "Copied text";
1313
})
1414
.catch(() => {
1515
return null;
16-
});
16+
}) as string;
17+
return clipboardResult;
1718
}
1819
return null;
1920
};

packages/docs/src/lib/types.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export interface DirectoryData {
2+
title: string;
3+
}
14
export interface NavItems {
25
[path: string]: {
36
title: string;

packages/docs/src/lib/utils/getNavigationItems.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { MarkdocModule } from "markdoc-svelte";
22

3-
import type { NavItems } from "$lib/types";
3+
import type { DirectoryData, NavItems } from "$lib/types";
44

55
export const getNavigationItems = async (): Promise<NavItems> => {
66
const allPages = import.meta.glob("/src/content/docs/**/*.mdoc");
@@ -57,12 +57,12 @@ export const getNavigationItems = async (): Promise<NavItems> => {
5757
dirPath.match(dirName),
5858
);
5959

60-
const [_, dirData] = matchingDir;
60+
const [_, getDirData] = matchingDir;
6161

6262
return {
6363
...existingNavItems,
6464
[dirName]: {
65-
title: (await dirData()).title,
65+
title: ((await getDirData()) as DirectoryData).title,
6666
children: {
6767
[slug]: {
6868
title: pageTitle,

0 commit comments

Comments
 (0)