add TYPE property to UmbContextToken to get the generic type

This commit is contained in:
Jacob Overgaard
2023-03-01 11:02:01 +01:00
parent 864b1e01c1
commit 7e3ab09ba3

View File

@@ -1,4 +1,15 @@
export class UmbContextToken<T = unknown> {
/**
* Get the type of the token
*
* @public
* @type {T}
* @memberOf UmbContextToken
* @example `typeof MyToken.TYPE`
* @returns undefined
*/
readonly TYPE: T = undefined as never;
/**
* @param alias Unique identifier for the token,
* @param _desc Description for the token,
@@ -7,13 +18,6 @@ export class UmbContextToken<T = unknown> {
*/
constructor(protected alias: string, protected _desc?: string) {}
/**
* @internal
*/
get multi(): UmbContextToken<Array<T>> {
return this as UmbContextToken<Array<T>>;
}
/**
* This method must always return the unique alias of the token since that
* will be used to look up the token in the injector.