Fix TypeScript errors in "Configuration" & "Routing and navigation" code snippets#14089
Fix TypeScript errors in "Configuration" & "Routing and navigation" code snippets#14089ArmandPhilippot wants to merge 25 commits into
Conversation
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
|
Preview deployment ✅ Deployment complete!
|
|
This is now focused on "Configuration" & "Routing and navigation" code snippets, follow-up PRs:
Well, the PR is smaller but the description is now bigger. 😅 Feel free to ask for more details! |
ae57043 to
a904919
Compare
|
I extracted a few changes in follow-up PRs to ease the review: |
Description (required)
Fixes TypeScript errors in "Configuration" and "Routing and navigation" pages:
prefetch.mdxdocument.getElementByIdcan benullforEachdoesn't work withHTMLCollectionOfgetAttributecan returnnullinternationalization.mdxctx.urlis aURL,startsWithis not availableredirectToDefaultLocale(we should passctx)middleware.mdxtypescript.mdx:as Paramswhensatisfies GetStaticPathsis used is misleading: we don't need a cast hereTo help review and explain my changes I made a commit per code snippet (with a few exceptions where the changes were the same), with a short explanation of why in the commit message. But, I also repeat the explanation above. Choose what is easier for you!
If you're interested in the "why," here's my reasoning:
Code snippets should work with minimal friction for users: TypeScript red squiggles or missing imports provide bad DX, especially for people new with web dev. I guess this can help AI too now.
Also, since Astro v5, the default Typescript preset is
strictinstead ofbase. This means TypeScript is now reporting errors for some code snippets that could work before. We had some reports before, we fixed them. We still get new reports from time to time, so I'm starting to check all our code snippets.re: formatting changes
In the core repo they tend to use single quotes, but in a new project without custom configuration (in VSCode, with the Astro extension enabled), this is automatically formatted with double quotes: I think minimal visual changes for the user are a good thing. So, I haven't undone the formatting changes made when correcting the code snippets.
kinda related to #10073
Related issues & labels (optional)