diff --git a/framework/core/js/src/@types/global.d.ts b/framework/core/js/src/@types/global.d.ts index 7e537b1ec..a0d84324f 100644 --- a/framework/core/js/src/@types/global.d.ts +++ b/framework/core/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.