Skip to content

Commit

Permalink
feat: add isIntrinsicErrorType
Browse files Browse the repository at this point in the history
fix #226
  • Loading branch information
RebeccaStevens committed Jun 18, 2023
1 parent ef35c44 commit 4f56bce
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/types/typeGuards/intrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,40 @@ export function isIntrinsicBigIntType(
return isTypeFlagSet(type, ts.TypeFlags.BigInt);
}

/**
* An "error" intrinsic type.
*
* This refers to a type generated when TypeScript encounters an error while
* trying to resolve the type.
*
* @category Type Types
*/
export interface IntrinsicErrorType extends IntrinsicType {
intrinsicName: "error";
}

/**
* Determines whether the given type is the "error" intrinsic type.
*
* The intrinsic error type occurs when TypeScript encounters an error while
* trying to resolve the type.
*
* @category Types - Type Guards
* @example
* ```ts
* declare const type: ts.Type;
*
* if (isIntrinsicErrorType(type)) {
* // ...
* }
* ```
*/
export function isIntrinsicErrorType(
type: ts.Type
): type is IntrinsicErrorType {
return isIntrinsicType(type) && type.intrinsicName === "error";
}

/**
* A "symbol" intrinsic type.
*
Expand Down

0 comments on commit 4f56bce

Please sign in to comment.