feat: Aggiunta nuova proprietà `attrsTypes` ai componenti

La proprietà `attrsTypes`, similmente a `prop` di React, permette la tipizzazione degli attributi dei componenti Mithril custom
This commit is contained in:
Maicol Battistini 2022-03-10 14:11:16 +01:00
parent 3c5c2f6586
commit 4fd89f2cba
No known key found for this signature in database
GPG Key ID: 4FDB0F87CDB1D34A
2 changed files with 10 additions and 0 deletions

View File

@ -61,6 +61,12 @@ export default class Component<A> implements m.Component<A>, ClassComponent<A> {
*/
attrs: Attributes<string>;
/**
* The types of the attributes passed into the component. They are used by Typescript to
* correctly help typing them.
*/
attrsTypes: A;
constructor() {
this.element = undefined as unknown as Element;
this.attrs = undefined as unknown as Attributes<string>;

View File

@ -71,5 +71,9 @@ declare global {
'text-field': JSXElement<TextField>;
'top-app-bar': JSXElement<TopAppBar>;
}
interface ElementAttributesProperty {
attrsTypes?: any;
}
}
}