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

no-nullable-attribute-binding not working properly and cannot turn off #253

Open
ggecy opened this issue Apr 28, 2022 · 2 comments
Open

Comments

@ggecy
Copy link

ggecy commented Apr 28, 2022

Hello, I have the following variable defined (and computed later on):

let className: string | null = null

and then used in a template

result = render(html`<span class="${ifDefined(className)}">${model.item.values[columnIndex]}</span>`, root);

which shows the following error for class attribute: This attribute binds the type 'string | null' which can end up binding the string 'null'. Use the 'ifDefined' directive and strict null check?lit-plugin(no-nullable-attribute-binding)(2314).

This shouldn't be an error according to official lit element documentation and implementation of ifDefined directive - it works with both undefined and null values and ignores the attribute : For AttributeParts, sets the attribute if the value is defined and removes the attribute if the value is undefined (undefined or null)

I have also tried setting the no-nullable-attribute-binding to off in settings yet the error is still shown.

@jesseditson
Copy link

Just giving this a quick bump as I've otherwise been finding this lib incredibly helpful but this bug has really cramped my CI.

@nathanbrnrd
Copy link

This is definitely polluting my IDE with error messages that are not relevant.
A quick patch that I use is to install the ts-lit-plugin and change error level in the tsconfig.json:

"plugins": [
        {
          "name": "ts-lit-plugin",
          "rules": {
            "no-nullable-attribute-binding": "warning",
          }
        }
      ]

Note that setting the rule value to "off" doesn't work

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

No branches or pull requests

3 participants