📄 typeFlagUtils¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 2 |
| 📊 Variables & Constants | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/type-utils/src/typeFlagUtils.ts
Variables & Constants¶
| Name | Type | Kind | Value | Exported |
|---|---|---|---|---|
ANY_OR_UNKNOWN |
number |
const | ts.TypeFlags.Any \| ts.TypeFlags.Unknown |
✗ |
Functions¶
getTypeFlags(type: ts.Type): ts.TypeFlags¶
Gets all of the type flags in a type, iterating through unions automatically.
Calls:
tsutils.unionConstituents
Internal Comments:
// @ts-expect-error Since typescript 5.0, this is invalid, but uses 0 as the default value of TypeFlags. (x2)
Code
isTypeFlagSet(type: ts.Type, flagsToCheck: ts.TypeFlags, isReceiver: boolean): boolean¶
Parameters:
flagsToCheckany: The composition of one or morets.TypeFlags.isReceiverany: Whether the type is a receiving type (e.g. the type of a called function's parameter).
Tags: @remarks Note that if the type is a union, this function will decompose it into the
parts and get the flags of every union constituent. If this is not desired,
use the isTypeFlag function from tsutils.
Raw JSDoc
/**
* @param flagsToCheck The composition of one or more `ts.TypeFlags`.
* @param isReceiver Whether the type is a receiving type (e.g. the type of a
* called function's parameter).
* @remarks
* Note that if the type is a union, this function will decompose it into the
* parts and get the flags of every union constituent. If this is not desired,
* use the `isTypeFlag` function from tsutils.
*/
Calls:
getTypeFlags
Internal Comments:
Code
export function isTypeFlagSet(
type: ts.Type,
flagsToCheck: ts.TypeFlags,
/** @deprecated This params is not used and will be removed in the future.*/
isReceiver?: boolean,
): boolean {
const flags = getTypeFlags(type);
// eslint-disable-next-line @typescript-eslint/no-deprecated -- not used
if (isReceiver && flags & ANY_OR_UNKNOWN) {
return true;
}
return (flags & flagsToCheck) !== 0;
}
Generated by Syntax Scribe