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: Don’t require getCollection() filter to be a type guard #5998

Merged
merged 1 commit into from
Jan 27, 2023

Conversation

andersk
Copy link
Contributor

@andersk andersk commented Jan 26, 2023

Changes

Commit dabce6b (#5970) broke the use of a plain boolean filter. Add an overload similar to TypeScript’s Array#filter overload.

#5970 (comment) (cc @bholmesdev)

Testing

Tested with my company blog, which uses const posts = await getCollection("posts", (post) => post.data.author === author).

Docs

No documentation change needed.

@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2023

🦋 Changeset detected

Latest commit: 6ae244d

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 26, 2023
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.

Ahh nice catch, looks good to me! Sorry for the breakage.

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.

Eep! I remember testing this case but I'll trust if it broke on your end. Let me know if this nit also solves your issue.

packages/astro/src/content/template/types.d.ts Outdated Show resolved Hide resolved
Commit dabce6b (withastro#5970) broke the use
of a plain boolean filter.  Add an overload similar to TypeScript’s
Array#filter overload:

https://github.com/microsoft/TypeScript/blob/v4.9.4/lib/lib.es5.d.ts#L1442-L1453

Signed-off-by: Anders Kaseorg <[email protected]>
@bholmesdev bholmesdev merged commit 12c6834 into withastro:main Jan 27, 2023
This was referenced Jan 27, 2023
kuanoni added a commit to kuanoni/astro-portfolio that referenced this pull request Feb 21, 2023
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.

3 participants