mirror of
https://github.com/grafana/grafana.git
synced 2025-01-06 22:23:19 -06:00
bc7ed4baab
* use jest.mocked instead of yucky any * remove more anys in favor of jest.mocked * fix stray unused variables
19 lines
489 B
TypeScript
19 lines
489 B
TypeScript
export function assertInstanceOf<T extends { new (...args: unknown[]): InstanceType<T> }>(
|
|
value: unknown,
|
|
type: T
|
|
): InstanceType<T> {
|
|
if (!(value instanceof type)) {
|
|
throw new Error(`Expected value to be an instanceof ${typeof type} but got ${typeof value}`);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
export function assertIsDefined<T>(value: T | null | undefined): T {
|
|
if (value == null) {
|
|
throw new Error(`Expected value to not be null but got ${typeof value}`);
|
|
}
|
|
|
|
return value;
|
|
}
|