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

[TSX] infer props and params from getStaticPaths #873

Merged
merged 3 commits into from
Oct 4, 2023

Conversation

natemoo-re
Copy link
Member

@natemoo-re natemoo-re commented Oct 3, 2023

Changes

  • This PR is relevant for consumers of our TSX output (namely language tools)
  • Adds new generated output if an Astro component has a getStaticPaths export
  • Astro.props and Astro.params can be inferred from the return value of getStaticPaths
    • Existing Props definitions take precedence over inferred definitions, so this should be compatible with the existing recommended pattern below:
    type Params = InferGetStaticParamsType<typeof getStaticPaths>;
    type Props = InferGetStaticPropsType<typeof getStaticPaths>;
  • Ideally we'd also be able to inject a satisfies clause for getStaticPaths itself, but that can be left for a follow-up PR

Testing

Tests added

Docs

We should update the docs when this lands upstream in the language tools!

@changeset-bot
Copy link

changeset-bot bot commented Oct 3, 2023

🦋 Changeset detected

Latest commit: f6d9524

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

This PR includes changesets to release 1 package
Name Type
@astrojs/compiler Minor

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

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.

Awesome work! People will be very happy about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants