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

Types: ShrinkRayOptions.filter should be optional #52

Open
karol-majewski opened this issue Apr 22, 2020 · 0 comments · May be fixed by #53
Open

Types: ShrinkRayOptions.filter should be optional #52

karol-majewski opened this issue Apr 22, 2020 · 0 comments · May be fixed by #53

Comments

@karol-majewski
Copy link

Hello and thank you for your work.

I noticed that when I want to pass some options, I'm required to provide filter even when I have no custom filter to provide.

Offending code

app.use(
  shrinkRay({
    brotli: {
      mode: 11,
    },
  }),
);

Error message:

Argument of type '{ brotli: { mode: number; }; }' is not assignable to parameter of type 'ShrinkRayOptions'.
  Property 'filter' is missing in type '{ brotli: { mode: number; }; }' but required in type 'ShrinkRayOptions'.ts(2345)

Workaround

I could do this:

app.use(
  shrinkRay({
    brotli: {
      mode: 11,
    },
    filter: shrinkRay.filter,
  }),
);

but it strikes me as awkward and slightly redundant since adding filter: shrinkRay.filter doesn't affect the functionality in any way.

Solution

This:

interface ShrinkRayOptions extends Filterable {

should be changed to:

- interface ShrinkRayOptions extends Filterable {
+ interface ShrinkRayOptions extends Partial<Filterable> {

What do you think?

OliverJAsh added a commit to OliverJAsh/shrink-ray that referenced this issue May 7, 2020
@OliverJAsh OliverJAsh linked a pull request May 7, 2020 that will close this issue
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 a pull request may close this issue.

1 participant