📄 src/predicates¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 11 |
| 📦 Imports | 2 |
| 📊 Variables & Constants | 2 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/type-utils/src/predicates.ts
📦 Imports¶
| Name | Source |
|---|---|
debug |
debug |
isTypeFlagSet |
./typeFlagUtils |
Variables & Constants¶
| Name | Type | Kind | Value | Exported |
|---|---|---|---|---|
Nullable |
number |
const | ts.TypeFlags.Undefined \| ts.TypeFlags.Null |
✗ |
ObjectFlagsType |
number |
const | ts.TypeFlags.Any \| Nullable \| ts.TypeFlags.Never \| ts.TypeFlags.Object \| ... |
✗ |
Functions¶
isNullableType(type: ts.Type): boolean¶
Checks if the given type is (or accepts) nullable
Calls:
isTypeFlagSet (from ./typeFlagUtils)
Code
isTypeArrayTypeOrUnionOfArrayTypes(type: ts.Type, checker: ts.TypeChecker): boolean¶
Checks if the given type is either an array type, or a union made up solely of array types.
Raw JSDoc
Calls:
tsutils.unionConstituentschecker.isArrayType
Code
isTypeNeverType(type: ts.Type): boolean¶
Returns: undefined
true if the type is never
Calls:
isTypeFlagSet (from ./typeFlagUtils)
Code
isTypeUnknownType(type: ts.Type): boolean¶
Returns: undefined
true if the type is unknown
Calls:
isTypeFlagSet (from ./typeFlagUtils)
Code
isTypeReferenceType(type: ts.Type): type is ts.TypeReference¶
Parameters:
typets.Type
Returns: type is ts.TypeReference
Code
isTypeAnyType(type: ts.Type): boolean¶
Returns: undefined
true if the type is any
Calls:
isTypeFlagSet (from ./typeFlagUtils)log
Code
isTypeAnyArrayType(type: ts.Type, checker: ts.TypeChecker): boolean¶
Returns: undefined
true if the type is any[]
Calls:
checker.isArrayTypeisTypeAnyTypechecker.getTypeArguments
Code
isTypeUnknownArrayType(type: ts.Type, checker: ts.TypeChecker): boolean¶
Returns: undefined
true if the type is unknown[]
Calls:
checker.isArrayTypeisTypeUnknownTypechecker.getTypeArguments
Code
typeIsOrHasBaseType(type: ts.Type, parentType: ts.Type): boolean¶
Returns: undefined
Whether a type is an instance of the parent type, including for the parent's base types.
Raw JSDoc
Calls:
parentType.getSymboltype.getSymboltype.getBaseTypestypeAndBaseTypes.pushbaseType.getSymbol
Code
export function typeIsOrHasBaseType(
type: ts.Type,
parentType: ts.Type,
): boolean {
const parentSymbol = parentType.getSymbol();
if (!type.getSymbol() || !parentSymbol) {
return false;
}
const typeAndBaseTypes = [type];
const ancestorTypes = type.getBaseTypes();
if (ancestorTypes) {
typeAndBaseTypes.push(...ancestorTypes);
}
for (const baseType of typeAndBaseTypes) {
const baseSymbol = baseType.getSymbol();
if (baseSymbol?.name === parentSymbol.name) {
return true;
}
}
return false;
}
isTypeBigIntLiteralType(type: ts.Type): type is ts.BigIntLiteralType¶
Parameters:
typets.Type
Returns: type is ts.BigIntLiteralType
Calls:
isTypeFlagSet (from ./typeFlagUtils)
Code
isTypeTemplateLiteralType(type: ts.Type): type is ts.TemplateLiteralType¶
Parameters:
typets.Type
Returns: type is ts.TemplateLiteralType
Calls:
isTypeFlagSet (from ./typeFlagUtils)
Code
Generated by Syntax Scribe