From 6bba3d8e02b95ecee7f9c945b6ee33b4c4ba755d Mon Sep 17 00:00:00 2001 From: HiDeoo Date: Tue, 8 Oct 2024 00:19:44 +0200 Subject: Fix type-checking issue (#2388) * feat: add docs typecheck script * fix: type-checking * chore: add changeset--- .changeset/seven-falcons-tie.md | 5 ++ docs/package.json | 3 +- package.json | 2 +- packages/starlight/index.ts | 1 + packages/starlight/virtual-internal.d.ts | 149 +++++++++++++++++++++++++++++++ packages/starlight/virtual.d.ts | 149 ------------------------------- pnpm-lock.yaml | 13 ++- 7 files changed, 167 insertions(+), 155 deletions(-) create mode 100644 .changeset/seven-falcons-tie.md create mode 100644 packages/starlight/virtual-internal.d.ts diff --git a/.changeset/seven-falcons-tie.md b/.changeset/seven-falcons-tie.md new file mode 100644 index 00000000..6107fe3b --- /dev/null +++ b/.changeset/seven-falcons-tie.md @@ -0,0 +1,5 @@ +--- +'@astrojs/starlight': patch +--- + +Fixes a potential type-checking issue in Starlight projects. diff --git a/docs/package.json b/docs/package.json index 406383ba..b1029e70 100644 --- a/docs/package.json +++ b/docs/package.json @@ -10,6 +10,7 @@ "start": "astro dev", "build": "astro build", "preview": "astro preview", + "typecheck": "tsc --noEmit", "astro": "astro", "lunaria:build": "lunaria build", "grammars": "node grammars/generate.mjs" @@ -25,7 +26,7 @@ }, "devDependencies": { "pa11y-ci": "^3.0.1", - "starlight-links-validator": "^0.11.0", + "starlight-links-validator": "^0.12.1", "start-server-and-test": "^2.0.4" } } diff --git a/package.json b/package.json index 41c2ad50..0b33a3a1 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "size": "size-limit", "version": "pnpm changeset version && pnpm i --no-frozen-lockfile", "format": "prettier -w --cache --plugin prettier-plugin-astro .", - "typecheck": "astro check --minimumSeverity warning --noSync" + "typecheck": "astro check --minimumSeverity warning --noSync && pnpm --filter starlight-docs typecheck" }, "license": "MIT", "devDependencies": { diff --git a/packages/starlight/index.ts b/packages/starlight/index.ts index 50b1a87e..3859b630 100644 --- a/packages/starlight/index.ts +++ b/packages/starlight/index.ts @@ -5,6 +5,7 @@ */ /// /// +/// import mdx from '@astrojs/mdx'; import type { AstroIntegration } from 'astro'; diff --git a/packages/starlight/virtual-internal.d.ts b/packages/starlight/virtual-internal.d.ts new file mode 100644 index 00000000..312a4ede --- /dev/null +++ b/packages/starlight/virtual-internal.d.ts @@ -0,0 +1,149 @@ +declare module 'virtual:starlight/project-context' { + const ProjectContext: { + root: string; + srcDir: string; + trailingSlash: import('astro').AstroConfig['trailingSlash']; + build: { + format: import('astro').AstroConfig['build']['format']; + }; + }; + export default ProjectContext; +} + +declare module 'virtual:starlight/git-info' { + export function getNewestCommitDate(file: string): Date; +} + +declare module 'virtual:starlight/user-css' {} + +declare module 'virtual:starlight/user-images' { + type ImageMetadata = import('astro').ImageMetadata; + export const logos: { + dark?: ImageMetadata; + light?: ImageMetadata; + }; +} + +declare module 'virtual:starlight/collection-config' { + export const collections: import('astro:content').ContentConfig['collections'] | undefined; +} + +declare module 'virtual:starlight/components/Banner' { + const Banner: typeof import('./components/Banner.astro').default; + export default Banner; +} +declare module 'virtual:starlight/components/ContentPanel' { + const ContentPanel: typeof import('./components/ContentPanel.astro').default; + export default ContentPanel; +} +declare module 'virtual:starlight/components/PageTitle' { + const PageTitle: typeof import('./components/PageTitle.astro').default; + export default PageTitle; +} +declare module 'virtual:starlight/components/FallbackContentNotice' { + const FallbackContentNotice: typeof import('./components/FallbackContentNotice.astro').default; + export default FallbackContentNotice; +} +declare module 'virtual:starlight/components/DraftContentNotice' { + const DraftContentNotice: typeof import('./components/DraftContentNotice.astro').default; + export default DraftContentNotice; +} + +declare module 'virtual:starlight/components/Footer' { + const Footer: typeof import('./components/Footer.astro').default; + export default Footer; +} +declare module 'virtual:starlight/components/LastUpdated' { + const LastUpdated: typeof import('./components/LastUpdated.astro').default; + export default LastUpdated; +} +declare module 'virtual:starlight/components/Pagination' { + const Pagination: typeof import('./components/Pagination.astro').default; + export default Pagination; +} +declare module 'virtual:starlight/components/EditLink' { + const EditLink: typeof import('./components/EditLink.astro').default; + export default EditLink; +} + +declare module 'virtual:starlight/components/Header' { + const Header: typeof import('./components/Header.astro').default; + export default Header; +} +declare module 'virtual:starlight/components/LanguageSelect' { + const LanguageSelect: typeof import('./components/LanguageSelect.astro').default; + export default LanguageSelect; +} +declare module 'virtual:starlight/components/Search' { + const Search: typeof import('./components/Search.astro').default; + export default Search; +} +declare module 'virtual:starlight/components/SiteTitle' { + const SiteTitle: typeof import('./components/SiteTitle.astro').default; + export default SiteTitle; +} +declare module 'virtual:starlight/components/SocialIcons' { + const SocialIcons: typeof import('./components/SocialIcons.astro').default; + export default SocialIcons; +} +declare module 'virtual:starlight/components/ThemeSelect' { + const ThemeSelect: typeof import('./components/ThemeSelect.astro').default; + export default ThemeSelect; +} + +declare module 'virtual:starlight/components/Head' { + const Head: typeof import('./components/Head.astro').default; + export default Head; +} +declare module 'virtual:starlight/components/Hero' { + const Hero: typeof import('./components/Hero.astro').default; + export default Hero; +} +declare module 'virtual:starlight/components/MarkdownContent' { + const MarkdownContent: typeof import('./components/MarkdownContent.astro').default; + export default MarkdownContent; +} + +declare module 'virtual:starlight/components/PageSidebar' { + const PageSidebar: typeof import('./components/PageSidebar.astro').default; + export default PageSidebar; +} +declare module 'virtual:starlight/components/TableOfContents' { + const TableOfContents: typeof import('./components/TableOfContents.astro').default; + export default TableOfContents; +} +declare module 'virtual:starlight/components/MobileTableOfContents' { + const MobileTableOfContents: typeof import('./components/MobileTableOfContents.astro').default; + export default MobileTableOfContents; +} + +declare module 'virtual:starlight/components/Sidebar' { + const Sidebar: typeof import('./components/Sidebar.astro').default; + export default Sidebar; +} +declare module 'virtual:starlight/components/SkipLink' { + const SkipLink: typeof import('./components/SkipLink.astro').default; + export default SkipLink; +} +declare module 'virtual:starlight/components/ThemeProvider' { + const ThemeProvider: typeof import('./components/ThemeProvider.astro').default; + export default ThemeProvider; +} + +declare module 'virtual:starlight/components/PageFrame' { + const PageFrame: typeof import('./components/PageFrame.astro').default; + export default PageFrame; +} +declare module 'virtual:starlight/components/MobileMenuToggle' { + const MobileMenuToggle: typeof import('./components/MobileMenuToggle.astro').default; + export default MobileMenuToggle; +} +declare module 'virtual:starlight/components/MobileMenuFooter' { + const MobileMenuFooter: typeof import('./components/MobileMenuFooter.astro').default; + export default MobileMenuFooter; +} + +declare module 'virtual:starlight/components/TwoColumnContent' { + const TwoColumnContent: typeof import('./components/TwoColumnContent.astro').default; + export default TwoColumnContent; +} diff --git a/packages/starlight/virtual.d.ts b/packages/starlight/virtual.d.ts index f7475aa8..17ed33d5 100644 --- a/packages/starlight/virtual.d.ts +++ b/packages/starlight/virtual.d.ts @@ -2,157 +2,8 @@ declare module 'virtual:starlight/user-config' { const Config: import('./types').StarlightConfig; export default Config; } -declare module 'virtual:starlight/project-context' { - const ProjectContext: { - root: string; - srcDir: string; - trailingSlash: import('astro').AstroConfig['trailingSlash']; - build: { - format: import('astro').AstroConfig['build']['format']; - }; - }; - export default ProjectContext; -} - -declare module 'virtual:starlight/git-info' { - export function getNewestCommitDate(file: string): Date; -} - -declare module 'virtual:starlight/user-css' {} - -declare module 'virtual:starlight/user-images' { - type ImageMetadata = import('astro').ImageMetadata; - export const logos: { - dark?: ImageMetadata; - light?: ImageMetadata; - }; -} declare module 'virtual:starlight/plugin-translations' { const PluginTranslations: import('./utils/plugins').PluginTranslations; export default PluginTranslations; } - -declare module 'virtual:starlight/collection-config' { - export const collections: import('astro:content').ContentConfig['collections'] | undefined; -} - -declare module 'virtual:starlight/components/Banner' { - const Banner: typeof import('./components/Banner.astro').default; - export default Banner; -} -declare module 'virtual:starlight/components/ContentPanel' { - const ContentPanel: typeof import('./components/ContentPanel.astro').default; - export default ContentPanel; -} -declare module 'virtual:starlight/components/PageTitle' { - const PageTitle: typeof import('./components/PageTitle.astro').default; - export default PageTitle; -} -declare module 'virtual:starlight/components/FallbackContentNotice' { - const FallbackContentNotice: typeof import('./components/FallbackContentNotice.astro').default; - export default FallbackContentNotice; -} -declare module 'virtual:starlight/components/DraftContentNotice' { - const DraftContentNotice: typeof import('./components/DraftContentNotice.astro').default; - export default DraftContentNotice; -} - -declare module 'virtual:starlight/components/Footer' { - const Footer: typeof import('./components/Footer.astro').default; - export default Footer; -} -declare module 'virtual:starlight/components/LastUpdated' { - const LastUpdated: typeof import('./components/LastUpdated.astro').default; - export default LastUpdated; -} -declare module 'virtual:starlight/components/Pagination' { - const Pagination: typeof import('./components/Pagination.astro').default; - export default Pagination; -} -declare module 'virtual:starlight/components/EditLink' { - const EditLink: typeof import('./components/EditLink.astro').default; - export default EditLink; -} - -declare module 'virtual:starlight/components/Header' { - const Header: typeof import('./components/Header.astro').default; - export default Header; -} -declare module 'virtual:starlight/components/LanguageSelect' { - const LanguageSelect: typeof import('./components/LanguageSelect.astro').default; - export default LanguageSelect; -} -declare module 'virtual:starlight/components/Search' { - const Search: typeof import('./components/Search.astro').default; - export default Search; -} -declare module 'virtual:starlight/components/SiteTitle' { - const SiteTitle: typeof import('./components/SiteTitle.astro').default; - export default SiteTitle; -} -declare module 'virtual:starlight/components/SocialIcons' { - const SocialIcons: typeof import('./components/SocialIcons.astro').default; - export default SocialIcons; -} -declare module 'virtual:starlight/components/ThemeSelect' { - const ThemeSelect: typeof import('./components/ThemeSelect.astro').default; - export default ThemeSelect; -} - -declare module 'virtual:starlight/components/Head' { - const Head: typeof import('./components/Head.astro').default; - export default Head; -} -declare module 'virtual:starlight/components/Hero' { - const Hero: typeof import('./components/Hero.astro').default; - export default Hero; -} -declare module 'virtual:starlight/components/MarkdownContent' { - const MarkdownContent: typeof import('./components/MarkdownContent.astro').default; - export default MarkdownContent; -} - -declare module 'virtual:starlight/components/PageSidebar' { - const PageSidebar: typeof import('./components/PageSidebar.astro').default; - export default PageSidebar; -} -declare module 'virtual:starlight/components/TableOfContents' { - const TableOfContents: typeof import('./components/TableOfContents.astro').default; - export default TableOfContents; -} -declare module 'virtual:starlight/components/MobileTableOfContents' { - const MobileTableOfContents: typeof import('./components/MobileTableOfContents.astro').default; - export default MobileTableOfContents; -} - -declare module 'virtual:starlight/components/Sidebar' { - const Sidebar: typeof import('./components/Sidebar.astro').default; - export default Sidebar; -} -declare module 'virtual:starlight/components/SkipLink' { - const SkipLink: typeof import('./components/SkipLink.astro').default; - export default SkipLink; -} -declare module 'virtual:starlight/components/ThemeProvider' { - const ThemeProvider: typeof import('./components/ThemeProvider.astro').default; - export default ThemeProvider; -} - -declare module 'virtual:starlight/components/PageFrame' { - const PageFrame: typeof import('./components/PageFrame.astro').default; - export default PageFrame; -} -declare module 'virtual:starlight/components/MobileMenuToggle' { - const MobileMenuToggle: typeof import('./components/MobileMenuToggle.astro').default; - export default MobileMenuToggle; -} -declare module 'virtual:starlight/components/MobileMenuFooter' { - const MobileMenuFooter: typeof import('./components/MobileMenuFooter.astro').default; - export default MobileMenuFooter; -} - -declare module 'virtual:starlight/components/TwoColumnContent' { - const TwoColumnContent: typeof import('./components/TwoColumnContent.astro').default; - export default TwoColumnContent; -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e71d5b16..f8e8bb03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,8 +64,8 @@ importers: specifier: ^3.0.1 version: 3.0.1 starlight-links-validator: - specifier: ^0.11.0 - version: 0.11.0(@astrojs/starlight@packages+starlight)(astro@4.15.3) + specifier: ^0.12.1 + version: 0.12.1(@astrojs/starlight@packages+starlight)(astro@4.15.3) start-server-and-test: specifier: ^2.0.4 version: 2.0.4 @@ -2056,6 +2056,10 @@ packages: resolution: {integrity: sha512-H6qeTp03jrknklSn4bpT1/9+1xCAEIU2CnjcWPkicJy8A1SKuthanbvoHYMiv79/2W3Xn1XE4gfSJFzt2U3JSw==} dev: true + /@types/picomatch@2.3.3: + resolution: {integrity: sha512-Yll76ZHikRFCyz/pffKGjrCwe/le2CDwOP5F210KQo27kpRE46U2rDnzikNlVn6/ezH3Mhn46bJMTfeVTtcYMg==} + dev: true + /@types/sax@1.2.4: resolution: {integrity: sha512-pSAff4IAxJjfAXUG6tFkO7dsSbTmf8CtUpfhhZ5VhkRpC4628tJhh3+V6H1E+/Gs9piSzYKT5yzHO5M4GG9jkw==} dependencies: @@ -6777,14 +6781,15 @@ packages: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} dev: true - /starlight-links-validator@0.11.0(@astrojs/starlight@packages+starlight)(astro@4.15.3): - resolution: {integrity: sha512-7mKiP0xAS8ItKy8QAIkmeNYbzI4w0WD0pOYoTPa1xMNbz+qYr/QWT+a40QO/Z2XYJLzzQn47yomupUfI89wheg==} + /starlight-links-validator@0.12.1(@astrojs/starlight@packages+starlight)(astro@4.15.3): + resolution: {integrity: sha512-LhRuGaI9Rp7c7ltwcG0BfCZuAN1d15oYbDB4jXblJ6zsiFcrSGHNlDnKXJHEJZ6XhJ+eOpd1IsHLFLh5Sq6uHg==} engines: {node: '>=18.14.1'} peerDependencies: '@astrojs/starlight': '>=0.15.0' astro: '>=4.0.0' dependencies: '@astrojs/starlight': link:packages/starlight + '@types/picomatch': 2.3.3 astro: 4.15.3(@types/node@18.16.19)(typescript@5.4.5) github-slugger: 2.0.0 hast-util-from-html: 2.0.1 -- cgit