Skip to main content
Module

x/deno2node/src/deps.deno.ts>TypePredicateNode

Compile your Deno project to run on Node.js.
Go to Latest
class TypePredicateNode
extends TypeNode<ts.TypePredicateNode>
import { TypePredicateNode } from "https://deno.land/x/deno2node@v1.7.1/src/deps.deno.ts";

A type predicate node which says the specified parameter name is a specific type if the function returns true.

Examples:

  • param is string in declare function isString(param: unknown): param is string;.
  • asserts condition in declare function assert(condition: any): asserts condition;.

Methods

getAssertsModifier(): Node<ts.AssertsKeyword> | undefined

Gets the asserts modifier if it exists.

getAssertsModifierOrThrow(message?: string | (() => string)): Node<ts.AssertsKeyword>

Gets the asserts modifier if it exists or throws otherwise.

Gets the parameter name node

getParent(): NodeParentType<ts.TypePredicateNode>
getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypePredicateNode>>
getTypeNode(): TypeNode | undefined

Gets the type name if it exists or returns undefined when it asserts a condition.

getTypeNodeOrThrow(message?: string | (() => string)): TypeNode

Gets the type name if it exists or throws when it asserts a condition.

Gets if the type predicate has an asserts modifier (ex. asserts condition).