Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
23 lines
614 B
Plaintext
23 lines
614 B
Plaintext
/**
|
|
* Ensure the type of a value
|
|
*
|
|
* 确认类型
|
|
*
|
|
* @example
|
|
* ```js
|
|
* import { ensureType } from 'is-what-type';
|
|
*
|
|
* const value: string | number | boolean | null | undefined | symbol | bigint = null;
|
|
const whatType = typeof value;
|
|
|
|
if (ensureType<object>(value, whatType === 'object')) {
|
|
Object.keys(value); // Throws TypeError: Cannot convert undefined or null to object
|
|
}
|
|
* ```
|
|
*
|
|
* @param value - The value to check
|
|
* @param checked - If the type is already checked
|
|
* @returns
|
|
*/
|
|
export declare function ensureType<T = unknown>(value: unknown, checked: boolean): value is T;
|