Add .d.ts file to astro package for language-tools consumption #2711
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
This adds a .d.ts file to the Astro package describing the global Astro object. It's intended to be used by the language-server and the ts-plugin to provide typechecking without needing to maintain separate (and often outdated) .d.ts files there. This will be followed by a PR in the language-tools to remove the outdated .d.ts files (fixing withastro/language-tools#170) and import this file instead
This bring many advantages, notably the types we can now provide to the users being based on our own internal types, they're always up to date and we can show the JSDoc comments to our users. Additionally, I added a reference to
vite/client
in it since we depends on it for many of our features (importMeta, assets imports etc)Side note: I tried to type getStaticPaths but it didn't work. It seems like since getStaticPaths gets exported, TypeScript doesn't apply the types to it. That's unfortunate, if anyone has a solution, I'll gladly add it to this PR
Testing
No tests needed
Docs
No docs needed