Skip to content

fix: Don’t require getCollection() filter to be a type guard#5998

Merged
bholmesdev merged 1 commit into
withastro:mainfrom
andersk:collection-filter-overload
Jan 27, 2023
Merged

fix: Don’t require getCollection() filter to be a type guard#5998
bholmesdev merged 1 commit into
withastro:mainfrom
andersk:collection-filter-overload

Conversation

@andersk
Copy link
Copy Markdown
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
Copy Markdown

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
@andersk andersk force-pushed the collection-filter-overload branch from 6588286 to 387e00e Compare January 26, 2023 20:54
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread packages/astro/src/content/template/types.d.ts Outdated
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 <andersk@mit.edu>
@andersk andersk force-pushed the collection-filter-overload branch from 3448a0a to 6ae244d Compare January 26, 2023 22:11
@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