Skip to content

fix(removeAttributesBySelector): mark omitted properties as optional - #2326

Open
folliehiyuki wants to merge 1 commit into
svg:mainfrom
folliehiyuki:fill-builtin-plugins
Open

folliehiyuki wants to merge 1 commit into
svg:mainfrom
folliehiyuki:fill-builtin-plugins

Conversation

@folliehiyuki

Copy link
Copy Markdown

At the current state, if a user defines the config as below, TypeScript fails to match it against either AttributesBySelector or AttributesBySelectors, falling back to CustomPlugin type (which produces the error missing fn property).

{
  plugins: [
    {
      name: "removeAttributesBySelector",
      params: {
        selector: ":root",
        attributes: "class",
      },
    },
  ],
}

Making the properties optional never avoids the issue. I threw in the type hint for the params variable as a bonus 😄

Ref: https://effectivetypescript.com/2021/11/11/optional-never/

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 this pull request may close these issues.

1 participant