Son CV dans un terminal web en Javascript! https://terminal-cv.gregandev.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
terminal-cv/node_modules/utility-types/dist/aliases-and-guards.d.ts

53 lines
2.1 KiB

/**
* 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<Various, Primitive>
*/
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<Various, Falsy>;
*/
export declare type Falsy = false | '' | 0 | 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;