UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

48 lines (47 loc) 1.89 kB
import * as ts from "typescript"; import { Node } from "./../compiler"; import { NotImplementedError } from "./NotImplementedError"; /** * Thows if not a type. * @param value - Value to check the type of. * @param expectedType - Expected type. * @param argName - Argument name. */ export declare function throwIfNotType(value: any, expectedType: string, argName: string): void; /** * Throws if the value is not a string or is whitespace. * @param value - Value to check. * @param argName - Arg name. */ export declare function throwIfNotStringOrWhitespace(value: string, argName: string): void; /** * Throws a NotImplementedError if a node doesn't match the expected syntax kind. * @param node - Node. * @param syntaxKind - Syntax kind that's expected. * @param message - Optional message to throw. */ export declare function throwIfNotSyntaxKind(node: Node, syntaxKind: ts.SyntaxKind, message?: string): void; /** * Throws an ArgumentOutOfRangeError if an argument's value is out of an inclusive range. * @param value - Value. * @param range - Range. * @param argName - Argument name. */ export declare function throwIfOutOfRange(value: number, range: [number, number], argName: string): void; /** * Gets an error saying that a feature is not implemented for a certain syntax kind. * @param syntaxKind - Syntax kind that isn't implemented. */ export declare function getNotImplementedForSyntaxKindError(syntaxKind: ts.SyntaxKind): NotImplementedError; /** * Throws an Argument * @param value * @param argName */ export declare function throwIfNegative(value: number, argName: string): void; /** * Throws when the value is null or undefined * @param value - Value to check. * @param errorMessage - Error message to throw when not defined. */ export declare function throwIfNullOrUndefined<T>(value: T | undefined, errorMessage: string | (() => string)): T;