Skip to content

Commit

Permalink
Fix type-checking issue (#2388)
Browse files Browse the repository at this point in the history
* feat: add docs typecheck script

* fix: type-checking

* chore: add changeset
  • Loading branch information
HiDeoo authored Oct 7, 2024
1 parent 0b4823d commit 6bba3d8
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 155 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-falcons-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Fixes a potential type-checking issue in Starlight projects.
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions packages/starlight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
/// <reference path="./locals.d.ts" />
/// <reference path="./i18n.d.ts" />
/// <reference path="./virtual.d.ts" />

import mdx from '@astrojs/mdx';
import type { AstroIntegration } from 'astro';
Expand Down
149 changes: 149 additions & 0 deletions packages/starlight/virtual-internal.d.ts
Original file line number Diff line number Diff line change
@@ -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;
}
149 changes: 0 additions & 149 deletions packages/starlight/virtual.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
13 changes: 9 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6bba3d8

Please sign in to comment.