Closed rstoneIDBS closed 4 months ago
And then I tried again :)
Adding:
constructor() {
super();
/** @type {'one' | 'two'} */
this.foo = 'hello';
}
gets it working, however I wonder if this is still an issue, i.e. having the types declared with the properties feels much nicer than having to spread them around into constructors too
Yeah, that wont work; for TS that won't work either, because TS is not aware that the properties defined in static properties
will get turned into actual class properties by lit internally. You could write a custom plugin to support this, but I doubt we'll support this in core
Yup - just bumped into the TS thing not working too :( TS aside, when you say it "won't work" - why does it work for the 'bar' property that doesn't have a default value?
I'm going to guess that its because 'lit' mode knows to look in the static properties, but also gets overridden when the generic CEM code finds a 'standard' property via the default value?
Checklist
--dev
flag to get more information?Playground Reproduction
Expected behavior In the playground example, I would expect the type for the
foo
property to be:I did experiment with trying to force the type of the default value via JSDoc comments but this didn't change the output