Skip to content

Commit

Permalink
VnodeElementTag must be either a string or a class.
Browse files Browse the repository at this point in the history
Unfortunately, TypeScript only supports strings and classes for JSX tags.
Therefore, our type definition should only allow for those two types.
see microsoft/TypeScript#14789 (comment)
  • Loading branch information
askvortsov1 committed Dec 14, 2021
1 parent b13bc70 commit 311e858
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions js/src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 311e858

Please sign in to comment.