lit
lit copied to clipboard
[reactive-element] Please reexport `Constructor` from lit-element/lit-element.js as well
Trying this with [email protected]
.
When writing mixins, you need the Constructor
type from lit-element. The typescript example at https://lit.dev/docs/composition/mixins/ also uses the Constructor
type, but doesn't specify where it comes from.
There is no common type in TypeScript unfortunately you can use. You still need to import this from the lit-element
package. The lit
package does not export it. So I'm still importing from multiple packages instead of just from lit
(one of the things I really like about the new lit is the single package imports instead of lit-element and lit-html).
Please reexport the Constructor
type from lit
as well.
I also have written a bunch of Mixins and think this should be included in TypeScript Library.
But If Lit was to include it, I think it also should include an AbstractConstructor
, which is supported as of TypeScript 4.2. It enables using mixins with abstract base classes.
type AbstractConstructor<T> = abstract new (...args: Array<any>) => T
Using it would look like
const Mixin = (Constructor: AbstractConstructor<SomeAbstractClass>) =>
class extends Constructor { }
@kevinpschaaf was actually working on this at one point, and I think hit some problems that made it not worth it. Maybe he can recall what it was.