runem / lit-analyzer

Monorepository for tools that analyze lit-html templates
MIT License
317 stars 36 forks source link

support complex attribute types #275

Open Kokujou opened 1 year ago

Kokujou commented 1 year ago

at the moment the only attribute types (from the static get properties()) are number, string, boolean, object, array. this is of course problematic if you pass more specific data. what i really desire and for which i'm waiting a long time now is a feature that we can say

static get properties(){
return {
users: { type: Array<UserModel>, reflect:true }
}
}

var products : ProductModel[]

<my-element .users="${products}"></my-element>

and it should give me a proper error in my error console. right now this is not happening and this is important especially when you have components representing a specific object. basically view models. e.g. in our project we have a product-tile representing a product and if you give a user it should fail.

it would be even better if you wouldn't even need to specify those static properties anymore, but simply read the correct type from the public property.

i even once tried it myself but failed due to javascript restrictions... as i don't know of a way to read public properties from a type name only. and i can't create an instance as creating instances of HTMLElements is not supported.

please think about a solution, that would be really, really, really helpful!