VnodeElementTag must be either a string or a class.

Unfortunately, TypeScript only supports strings and classes for JSX tags.
Therefore, our type definition should only allow for those two types.
see https://github.com/microsoft/TypeScript/issues/14789#issuecomment-412247771
This commit is contained in:
Alexander Skvortsov 2021-12-12 22:31:03 -05:00
parent 959662f2e2
commit 7b8d507139

View File

@ -21,9 +21,21 @@ declare type KeysOfType<Type extends object, Match> = {
*/
declare type KeyOfType<Type extends object, Match> = KeysOfType<Type, Match>[keyof Type];
declare type VnodeElementTag<Attrs = Record<string, unknown>, State = Record<string, unknown>> =
| string
| import('mithril').ComponentTypes<Attrs, State>;
type Component<A> = import('mithril').Component<A>;
declare type ComponentClass<
Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = { new (...args: any[]): Component<Attrs>, prototype: C };
/**
* Unfortunately, TypeScript only supports strings and classes for JSX tags.
* Therefore, our type definition should only allow for those two types.
*
* @see https://github.com/microsoft/TypeScript/issues/14789#issuecomment-412247771
*/
declare type VnodeElementTag<
Attrs = Record<string, unknown>,
C extends Component<Attrs> = Component<Attrs>
> = string | ComponentClass<Attrs, C>;
/**
* @deprecated Please import `app` from a namespace instead of using it as a global variable.