mirror of
https://github.com/flarum/core.git
synced 2025-07-16 14:26:25 +02:00
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:
18
framework/core/js/src/@types/global.d.ts
vendored
18
framework/core/js/src/@types/global.d.ts
vendored
@@ -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 KeyOfType<Type extends object, Match> = KeysOfType<Type, Match>[keyof Type];
|
||||||
|
|
||||||
declare type VnodeElementTag<Attrs = Record<string, unknown>, State = Record<string, unknown>> =
|
type Component<A> = import('mithril').Component<A>;
|
||||||
| string
|
|
||||||
| import('mithril').ComponentTypes<Attrs, State>;
|
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.
|
* @deprecated Please import `app` from a namespace instead of using it as a global variable.
|
||||||
|
Reference in New Issue
Block a user