/** * @see https://262.ecma-international.org/7.0/#sec-typeof-operator * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof */ export type EcmaType = 'undefined' | 'boolean' | 'number' | 'bigint' | 'string' | 'symbol' | 'function' | 'object'; /** * Type guards an EcmaType value in compile time * (unlike the `as` operator which allows to type cast any string as EcmaType). * * @throws TypeError - when the value in runtime is not an EcmaType. * * @since v0.9.0 */ export declare function ecmaType(type: EcmaType): EcmaType; /** * Returns true and narrows the variable type, if the given input string is an EcmaType. * * @since v0.9.0 */ export declare function isEcmaType(input: string): input is EcmaType; /** * Extended EcmaType to include checks for "null" and "array". * * Does not include "any", or "never", as these types cannot be checked in runtime. * * @see https://www.typescriptlang.org/docs/handbook/2/everyday-types.html */ export type TsType = EcmaType | 'null' | 'array' | 'unknown'; /** * Type guards a TsType value in compile time * (unlike the `as` operator which allows to type cast any string as TsType). * * @throws TypeError - when the value in runtime is not a TsType. * * @since v0.9.0 */ export declare function tsType(type: TsType): TsType; /** * Returns true and narrows the variable type, if the given input string is a TsType. * * @since v0.9.0 */ export declare function isTsType(input: string): input is TsType; /** * A conditional type to determine a TypeScript type of a given value. * * @see https://www.typescriptlang.org/docs/handbook/2/conditional-types.html * * @since v0.3.0 */ export type TypeOf = T extends undefined ? 'undefined' : T extends null ? 'null' : T extends boolean ? 'boolean' : T extends number ? 'number' : T extends bigint ? 'bigint' : T extends string ? 'string' : T extends symbol ? 'symbol' : T extends Function ? 'function' : T extends (infer _U)[] ? 'array' : T extends object ? 'object' : 'unknown'; /** * Returns the name of a TypeScript type of a given `value`. * * @since v0.3.0 */ export declare function typeOf(value: T | null | undefined): TypeOf & TsType; /** * Creates a predicate that returns `true`, if a passed argument is of a given TypeScript type. * * @since v0.3.0 */ export declare function isTypeOf(type: TsType): (value: unknown) => boolean; /** * Creates a predicate that returns `true`, if a passed argument is not of a given TypeScript type. * * @since v0.3.0 */ export declare function isNotTypeOf(type: TsType): (value: unknown) => boolean;