From 565fc9e871394caabef213bb38580587fefd57dd Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 9 Jan 2022 22:56:04 +0530 Subject: [PATCH] fix: properly type vitepress/theme --- package.json | 3 ++- src/node/markdown/plugins/containers.ts | 4 +++- src/node/serve/serve.ts | 2 +- src/shared/shared.ts | 2 +- theme.d.ts | 5 +++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index b850a552273d..a415e3ffe198 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "bin", "dist", "types", - "client.d.ts" + "client.d.ts", + "theme.d.ts" ], "scripts": { "dev": "run-s dev-shared dev-start", diff --git a/src/node/markdown/plugins/containers.ts b/src/node/markdown/plugins/containers.ts index 61dd7b91f885..9e3caa23e9b8 100644 --- a/src/node/markdown/plugins/containers.ts +++ b/src/node/markdown/plugins/containers.ts @@ -33,7 +33,9 @@ function createContainer(klass: string, defaultTitle: string): ContainerArgs { const info = token.info.trim().slice(klass.length).trim() if (token.nesting === 1) { if (klass === 'details') { - return `
${info ? `${info}` : ''}\n` + return `
${ + info ? `${info}` : '' + }\n` } return `

${ info || defaultTitle diff --git a/src/node/serve/serve.ts b/src/node/serve/serve.ts index 63a2aeddad34..778f7e72612e 100644 --- a/src/node/serve/serve.ts +++ b/src/node/serve/serve.ts @@ -23,7 +23,7 @@ export interface ServeOptions { export async function serve(options: ServeOptions = {}) { const port = options.port !== undefined ? options.port : 5000 const site = await resolveConfig(options.root, 'serve', 'production') - const base = trimChar(site?.site?.base ?? "", "/") + const base = trimChar(site?.site?.base ?? '', '/') const compress = compression() const serve = sirv(site.outDir, { diff --git a/src/shared/shared.ts b/src/shared/shared.ts index 1e1e0a5a4bf2..8742fded7772 100644 --- a/src/shared/shared.ts +++ b/src/shared/shared.ts @@ -6,7 +6,7 @@ export type { HeadConfig, LocaleConfig, Header, - DefaultTheme, + DefaultTheme } from '../../types/shared' export const EXTERNAL_URL_RE = /^https?:/i diff --git a/theme.d.ts b/theme.d.ts index dd034b53b298..576a81eff9f2 100644 --- a/theme.d.ts +++ b/theme.d.ts @@ -1,3 +1,4 @@ // so that users can do `import DefaultTheme from 'vitepress/theme'` -import DefaultTheme from './dist/client/theme-default/index' -export default DefaultTheme +import { Theme } from 'vitepress' +declare const theme: Theme +export default theme