-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix TSC5090 TypeScript compiler error #12358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
|
Hello! Thank you for opening your first PR to Astro’s Docs! 🎉 Here’s what will happen next:
|
Thanks you for taking the time to open a PR to fix an issue in docs! But, I tried to reproduce the issue following your steps and using
|
Hi @ArmandPhilippot. Thanks for your initial review.
I'm able to reproduce it on GitHub actions.
Commands:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, maybe I was too quick earlier. I'm so used to run astro check
in Astro projects that I misread the step 4. I didn't run tsc
... I've only tried running the dev server and astro check
. Both didn't complained and the path aliases was working just fine.
So, yes, I can see an error reported using tsc
both with the previous steps and the new ones! I wonder why astro check
didn't catch that and why this works (both with dev
and build
) without even a warning...
Looking at Typescript docs, it seems they always use relative paths when declaring paths aliases and I can confirm this works.
So, the changes looks good to me. Thank you both for fixing the docs and your patience! Welcome to team Docs! 🎉
Description (required)
It seems that TypeScript added at some point a check to forbid non-explicit relative
paths
whenbaseUrl
is not set. Asastro/tsconfigs/strict
does not definebaseUrl
, this can be reproduced in new astro projects following the Get Started guide and in the Astro docs itself.To reproduce this problem:
npm create astro@latest
.cd <project-name>
tsc
. The error is displayed:Apply the fix proposed by this PR and the error disappears.
Related issues & labels (optional)
What I did find, which documents the historical behavior and discussions around it (and shows where the restriction comes from), are these relevant points:
The historical decision that
paths
requiresbaseUrl
is in the original discussion about path mappings in the repository (this entry explains the semantics and explicitly states thatpaths
can only be used ifbaseUrl
is defined):Path mappings based module resolution microsoft/TypeScript#5039
Later proposals and discussions about allowing
paths
withoutbaseUrl
(showing that the requirement has been deliberate and debated since 2019):Proposal: Allow
paths
compilerOption withoutbaseUrl
microsoft/TypeScript#31869Examples of issues/errors in ecosystems (Nuxt, Svelte, etc.) that report exactly this message in tooling around 2022–2024 (proving that the diagnostic appears in modern versions; e.g. a Nuxt issue showing the message with TypeScript v5.2.2):
Non-relative paths are not allowed when 'baseUrl' is not set. Typescript v5.2.2 nuxt/nuxt#23157
First-time contributor to Astro Docs?
mondeja.