-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Astro Info
Astro v5.10.1
Node v24.2.0
System macOS (arm64)
Package Manager unknown
Output static
Adapter none
Integrations @vite-pwa/astro-integration
@playform/compress
@kindspells/astro-shield
@astrojs/sitemap
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
---
const fetchedCode = await fetchCode();
const code: string = fetchedCode.content;
const language: string = fetchedCode.language; // `fetchedCode` is something like { content: string; language: string }
---
<Code code={code} lang={language} />
^^^^ Type 'string' is not assignable to type 'BundledLanguage | SpecialLanguage | LanguageRegistration'. ts(2322)I'm writing a Component to embed GitHub code from my repo/gists into my website. Because of the strict nature of my code base I need to be able to specify a more strict type for language than just a string. Astro doesn't expose the BundledLanguage | SpecialLanguage | LanguageRegistration to me anywhere that I can see. And since [email protected] is a dependency of astro, not my project I don't have safe access to those types.
What's the expected result?
I expect that Astro would either not require a narrow type for the lang attribute, or would expose that type so that end-users can access it directly.
I will admit that this is a problem of my own making. I want to be super strict with my types, but I also don't want have to write or install (much) code just to make the linters and tsc happy.
If you provide me with some indication of how you think best to resolve this issue I am happy to submit a PR to Astro. For now I'm just disabling the complaint with a comment.
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.