Skip to content

Types: ShrinkRayOptions.filter should be optional #52

@karol-majewski

Description

@karol-majewski

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions