From 311e858c2bd53c3cd6a63e8a65d311790acf1188 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 12 Dec 2021 22:31:03 -0500 Subject: [PATCH] `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 --- js/src/@types/global.d.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/js/src/@types/global.d.ts b/js/src/@types/global.d.ts index 7e537b1ec..a0d84324f 100644 --- a/js/src/@types/global.d.ts +++ b/js/src/@types/global.d.ts @@ -21,9 +21,21 @@ declare type KeysOfType = { */ declare type KeyOfType = KeysOfType[keyof Type]; -declare type VnodeElementTag, State = Record> = - | string - | import('mithril').ComponentTypes; +type Component = import('mithril').Component; + +declare type ComponentClass< +Attrs = Record, C extends Component = Component> = { new (...args: any[]): Component, 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, + C extends Component = Component +> = string | ComponentClass; /** * @deprecated Please import `app` from a namespace instead of using it as a global variable.