/** * Primitive * @desc Type representing [`Primitive`](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) types in TypeScript: `string | number | bigint | boolean | symbol | null | undefined` * @example * type Various = number | string | object; * * // Expect: object * type Cleaned = Exclude */ export declare type Primitive = string | number | bigint | boolean | symbol | null | undefined; /** * Falsy * @desc Type representing falsy values in TypeScript: `false | "" | 0 | null | undefined` * @example * type Various = 'a' | 'b' | undefined | false; * * // Expect: "a" | "b" * Exclude; */ export declare type Falsy = false | '' | 0 | null | undefined; /** * Nullish * @desc Type representing [nullish values][https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#nullish-coalescing] in TypeScript: `null | undefined` * @example * type Various = 'a' | 'b' | undefined; * * // Expect: "a" | "b" * Exclude; */ export declare type Nullish = null | undefined; /** * Tests for one of the [`Primitive`](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) types using the JavaScript [`typeof`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) operator * * Clarification: TypeScript overloads this operator to produce TypeScript types if used in context of types. * * @param val The value to be tested * @returns If `val` is primitive. If used in the flow of the program typescript will infer type-information from this. * * @example * const consumer = (value: Primitive | Primitive[]) => { * if (isPrimitive(value)) { * return console.log('Primitive value: ', value); * } * // type of value now inferred as Primitive[] * value.map((primitive) => consumer(primitive)); * }; */ export declare const isPrimitive: (val: unknown) => val is Primitive; /** * Tests for Falsy by simply applying negation `!` to the tested `val`. * * The value is mostly in added type-information and explicity, * but in case of this simple type much the same can often be archived by just using negation `!`: * @example * const consumer = (value: boolean | Falsy) => { * if (!value) { * return ; * } * type newType = typeof value; // === true * // do stuff * }; */ export declare const isFalsy: (val: unknown) => val is Falsy; /** * Tests for Nullish by simply comparing `val` for equality with `null`. * @example * const consumer = (param: Nullish | string): string => { * if (isNullish(param)) { * // typeof param === Nullish * return String(param) + ' was Nullish'; * } * // typeof param === string * return param.toString(); * }; */ export declare const isNullish: (val: unknown) => val is null | undefined;