Skip to content
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

Add .d.ts file to astro package for language-tools consumption #2711

Merged
merged 2 commits into from
Mar 3, 2022
Merged

Add .d.ts file to astro package for language-tools consumption #2711

merged 2 commits into from
Mar 3, 2022

Conversation

Princesseuh
Copy link
Member

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)

image

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

@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2022

⚠️ No Changeset found

Latest commit: fca3dca

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 3, 2022
@matthewp
Copy link
Contributor

matthewp commented Mar 3, 2022

Small and simple, I like it!

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Very excited for this, it will be a huge help!

None of my feedback should be considered blocking, but I had a few thoughts.

packages/astro/app.d.ts Outdated Show resolved Hide resolved
packages/astro/app.d.ts Outdated Show resolved Hide resolved
packages/astro/app.d.ts Outdated Show resolved Hide resolved
packages/astro/package.json Outdated Show resolved Hide resolved
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, merge away!

@natemoo-re natemoo-re merged commit 519a5d8 into withastro:main Mar 3, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
…stro#2711)

* Add .d.ts file for user and language-server consumption

* Update according to feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants