[lit-plugin] no-incompatible-type-binding when types should be compatible
See original GitHub issueI’m using the lit-plugin in VSCode. I’m NOT using typescript, but instead, javascript with jsdoc type annotations.
It seems like when setting properties via the template binding, lit-plugin isn’t using the jsdoc annotation to determine the type, but rather the inferred type based on the value (or is it looking at the type in the static properties getter?):

The type for this.context.states is picked up correct as string[] and the component I’m assigning the property on has this constructor:
constructor() {
super();
/** @type {Array<string>} */
this.states = [];
/** @type {string?} */
this.selected = null;
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
lit-plugin - Visual Studio Marketplace
no-incompatible-type-binding. Assignments in your HTML are typed checked just like it would be in Typescript. The following examples are ...
Read more >ts-lit-plugin - npm
Typescript plugin that adds type checking and code completion to lit-html. Latest version: 1.2.1, last published: 2 years ago.
Read more >Typescript Type 'string' is not assignable to type - Stack Overflow
In this case, "Banana" , the type, extends "Orange" | "Apple" | "Banana" because it extends one of its components.
Read more >ts-lit-plugin/README.md - UNPKG
The CDN for ts-lit-plugin. ... 3, <b>Typescript plugin that adds type checking and code completion to lit-html</b></br>. 4, <sub><sub>.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there any update on this? I’m still seeing this issue in VSCode using lit-plugin 1.2.1.
Thanks! It seems like that version gets rid of my errors and such, but it’s still not correctly picking up the type from the jsdoc, but using the
typefrom properties instead. Here’s an example:In this case, child-element should be expecting a type of
Boolean[]for it’sthingsproperty, but it’s expectingany[]. If you make this change:changing the things.type property to
Stringthen the plugin is able to detect a problem here:<child-element .things=${this.items}></child-element>and complains that child-element.things should be a String instead of an String[].Meanwhile, the jsdoc typecast in the constructor of child-element seeming has no effect.