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

fix(astro): type generation for empty collections #11264

Merged
merged 4 commits into from
Jun 19, 2024

Conversation

Fryuni
Copy link
Member

@Fryuni Fryuni commented Jun 15, 2024

Changes

Testing

Expected types added on tests for astro sync

Docs

I don't think this needs any docs change

@Fryuni Fryuni requested a review from bholmesdev June 15, 2024 01:37
@Fryuni Fryuni self-assigned this Jun 15, 2024
Copy link

changeset-bot bot commented Jun 15, 2024

🦋 Changeset detected

Latest commit: 9470508

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

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

@Fryuni Fryuni added the feat: typescript Related to TypeScript (scope) label Jun 15, 2024
@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) and removed feat: typescript Related to TypeScript (scope) labels Jun 15, 2024
@Fryuni Fryuni added the feat: typescript Related to TypeScript (scope) label Jun 15, 2024
Co-authored-by: Florian Lefebvre <[email protected]>
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.

Looks great! Have a lot of hope for this generation

switch (resolvedType) {
case 'content':
if (collectionEntryKeys.length === 0) {
contentTypesStr += `${collectionKey}: Record<string, {\n id: string;\n slug: string;\n body: string;\n collection: ${collectionKey};\n data: ${dataType};\n render(): Render[".md"];\n}>;\n`;
Copy link
Contributor

Choose a reason for hiding this comment

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

That Render[".md"] may be the sign of a code smell. No need to refactor in this PR, but maybe we want a DefaultRender type?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I'll try to save some time to do a little refactor around that.

@ematipico ematipico merged commit 5a9c9a6 into main Jun 19, 2024
12 of 13 checks passed
@ematipico ematipico deleted the fryuni/empty-collection-type branch June 19, 2024 15:52
@astrobot-houston astrobot-houston mentioned this pull request Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: typescript Related to TypeScript (scope) pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty Content Collections with defined scema don't generate typescript types
4 participants