ts-api-utils - v3.0.0-rc.1 (original) (raw)

Utility functions for working with TypeScript's API. Successor to the wonderful tsutils.

ts-api-utils exports functions and types for working with TypeScript's node and type APIs. If you're working with ts.Nodes and/or ts.Types, this package is your friend. 💗

Installation

npm i ts-api-utils
yarn add ts-api-utils
pnpm add ts-api-utils

Usage

import * as tsutils from "ts-api-utils";

The most commonly used functions are type predicates not yet available on TypeScript. For example:

declare const node: ts.Node;

if (isAbstractKeyword(node)) {
    // ...
}

See the sidebar for the full list of available functions and types.

Tip: if a function you'd want to use appears to be missing, check whether it exists on TypeScript itself.

Supported Versions

ts-api-utils supports TypeScript versions 5.5.2 and above and Node versions 20.19.0 and above.