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

Move client types into Astro #3851

Merged
merged 6 commits into from
Jul 11, 2022
Merged

Move client types into Astro #3851

merged 6 commits into from
Jul 11, 2022

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Jul 7, 2022

Changes

  • Replaces vite/client with astro/client.
  • astro/client doesn't contain DOM references, so you don't get weird DOM types in your frontmatter.

Testing

  • No new ones, but existing tests would break if this was incorrect.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Jul 7, 2022

🦋 Changeset detected

Latest commit: f8e771e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
astro Patch
@e2e/astro-component Patch
@e2e/lit-component Patch
@e2e/preact-component Patch
@e2e/react-component Patch
@e2e/solid-component Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope) labels Jul 7, 2022
@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Jul 7, 2022
@github-actions github-actions bot removed the pkg: integration Related to any renderer integration (scope) label Jul 7, 2022
Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

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

Code looks good to me, however a docs update is needed. The types are referenced on the following pages :

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.

Looking' good! All the examples still say "// Add type definitions for our Vite runtime." above astro/client, though. Would remove or rephrase that.

Agree with @Princesseuh about making sure the docs get updated. Also roping in @tony-sull to comment on the image types.

examples/basics/tsconfig.json Outdated Show resolved Hide resolved
Comment on lines +68 to +80
// images
declare module '*.jpg' {
const src: string
export default src
}
declare module '*.jpeg' {
const src: string
export default src
}
declare module '*.png' {
const src: string
export default src
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this means @tony-sull can override these now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By override do you mean change them, then sure. If you mean override in his project, I'm not enough of a TS guru to know.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think typescript will let @astrojs/image re-declare these, but I'm not 100% sure. @matthewp the main need is for @astrojs/image to be able to define all image imports to something similar to

declare module '*.jpeg' {
  const metadata: {
    src: string
    width: number
    height: number
    format: string
  }
  export default metadata
}

Copy link
Member

Choose a reason for hiding this comment

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

I believe adding these to a @astrojs/image/client.d.ts file and then adding that to compilerOptions.include will override these. We don't want this to reference the @astrojs/image types unless @astrojs/image is installed.

@matthewp
Copy link
Contributor Author

matthewp commented Jul 8, 2022

Docs updated in this PR: withastro/docs#953

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.

LGTM!

Copy link
Contributor

@tony-sull tony-sull left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@bholmesdev bholmesdev left a comment

Choose a reason for hiding this comment

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

That's my type of PR!

@matthewp matthewp merged commit 21869a6 into main Jul 11, 2022
@matthewp matthewp deleted the client-types branch July 11, 2022 12:12
@astrobot-houston astrobot-houston mentioned this pull request Jul 11, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* Move client types into Astro

* Adds a changeset

* Fix path to local client

* Reference vite/client in our HMR types

* Add back in the expect-error

* Update types comment
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) pkg: example Related to an example package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants