tsutils
utilities for working with typescript's AST
Last updated 8 years ago by ajaff .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install tsutils 
SYNC missed versions from official npm registry.

Utility functions for working with typescript's AST

Greenkeeper badge

Usage

This package consists of two major parts: utilities and typeguard functions. By importing the project you will get both of them.

import * as utils from "tsutils";
utils.isIdentifier(node); // typeguard
utils.getLineRanges(sourceFile); // utilities

If you don't need everything offered by this package, you can select what should be imported. The parts that are not imported are never read from disk and may save some startup time and reduce memory consumtion.

If you only need typeguards you can explicitly import them:

import { isIdentifier } from "tsutils/typeguard";
// You can even distiguish between typeguards for nodes and types
import { isUnionTypeNode } from "tsutils/typeguard/node";
import { isUnionType } from "tsutils/typeguard/type";

If you only need the utilities you can also explicitly import them:

import { forEachComment, forEachToken } from "tsutils/util";

Typescript version dependency

This package is backwards compatible with typescript 2.8.0 at runtime although compiling might need a newer version of typescript installed.

Using typescript@next might work, but it's not officially supported. If you encounter any bugs, please open an issue.

For compatibility with older versions of TypeScript typeguard functions are separated by TypeScript version. If you are stuck on typescript@2.8, you should import directly from the submodule for that version:

// all typeguards compatible with typescript@2.8
import { isIdentifier } from "tsutils/typeguard/2.8";
// you can even use nested submodules
import { isIdentifier } from "tsutils/typeguard/2.8/node";

// all typeguards compatible with typescript@2.9 (includes those of 2.8)
import { isIdentifier } from "tsutils/typeguard/2.9";

// always points to the latest stable version (2.9 as of writing this)
import { isIdentifier } from "tsutils/typeguard";
import { isIdentifier } from "tsutils";

// always points to the typeguards for the next TypeScript version (3.0 as of writing this)
import { isIdentifier } from "tsutils/typeguard/next";

Note that if you are also using utility functions, you should prefer the relevant submodule:

// importing directly from 'tsutils' would pull in the latest typeguards
import { forEachToken } from 'tsutils/util';
import { isIdentifier } from 'tsutils/typeguard/2.8';

Current Tags

  • 3.21.0                                ...           latest (4 years ago)

94 Versions

  • 3.21.0                                ...           4 years ago
  • 3.20.0                                ...           4 years ago
  • 3.19.1                                ...           4 years ago
  • 3.19.0                                ...           4 years ago
  • 3.18.0                                ...           4 years ago
  • 3.17.1                                ...           5 years ago
  • 3.17.0                                ...           5 years ago
  • 3.16.0                                ...           5 years ago
  • 3.15.0                                ...           5 years ago
  • 3.14.1                                ...           5 years ago
  • 3.14.0                                ...           6 years ago
  • 3.13.0                                ...           6 years ago
  • 3.12.0                                ...           6 years ago
  • 3.11.0                                ...           6 years ago
  • 3.10.0                                ...           6 years ago
  • 3.9.1                                ...           6 years ago
  • 3.9.0                                ...           6 years ago
  • 3.8.0                                ...           6 years ago
  • 3.7.0                                ...           6 years ago
  • 3.6.0                                ...           6 years ago
  • 3.5.2                                ...           6 years ago
  • 3.5.1                                ...           6 years ago
  • 3.5.0                                ...           6 years ago
  • 3.4.0                                ...           6 years ago
  • 3.3.1                                ...           6 years ago
  • 3.3.0                                ...           6 years ago
  • 3.2.0                                ...           6 years ago
  • 3.1.0                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.29.0                                ...           6 years ago
  • 2.28.0                                ...           6 years ago
  • 2.27.2                                ...           6 years ago
  • 2.27.1                                ...           7 years ago
  • 2.27.0                                ...           7 years ago
  • 2.26.2                                ...           7 years ago
  • 2.26.1                                ...           7 years ago
  • 2.26.0                                ...           7 years ago
  • 2.25.1                                ...           7 years ago
  • 2.25.0                                ...           7 years ago
  • 2.24.0                                ...           7 years ago
  • 2.23.0                                ...           7 years ago
  • 2.22.2                                ...           7 years ago
  • 2.22.1                                ...           7 years ago
  • 2.22.0                                ...           7 years ago
  • 2.21.2                                ...           7 years ago
  • 2.21.1                                ...           7 years ago
  • 2.21.0                                ...           7 years ago
  • 2.20.0                                ...           7 years ago
  • 2.19.1                                ...           7 years ago
  • 2.19.0                                ...           7 years ago
  • 2.18.0                                ...           7 years ago
  • 2.17.1                                ...           7 years ago
  • 2.17.0                                ...           7 years ago
  • 2.16.0                                ...           7 years ago
  • 2.15.0                                ...           7 years ago
  • 2.14.0                                ...           7 years ago
  • 2.13.1                                ...           7 years ago
  • 2.13.0                                ...           7 years ago
  • 2.12.2                                ...           7 years ago
  • 2.12.1                                ...           7 years ago
  • 2.12.0                                ...           7 years ago
  • 2.11.2                                ...           7 years ago
  • 2.11.1                                ...           7 years ago
  • 2.11.0                                ...           7 years ago
  • 2.10.0                                ...           7 years ago
  • 2.9.0                                ...           7 years ago
  • 2.8.2                                ...           7 years ago
  • 2.8.1                                ...           7 years ago
  • 2.8.0                                ...           7 years ago
  • 2.7.1                                ...           7 years ago
  • 2.7.0                                ...           7 years ago
  • 2.6.1                                ...           7 years ago
  • 2.6.0                                ...           7 years ago
  • 2.5.1                                ...           7 years ago
  • 2.5.0                                ...           7 years ago
  • 2.4.0                                ...           8 years ago
  • 2.3.0                                ...           8 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.9.1                                ...           8 years ago
  • 1.9.0                                ...           8 years ago
  • 1.8.0                                ...           8 years ago
  • 1.7.0                                ...           8 years ago
  • 1.6.0                                ...           8 years ago
  • 1.5.0                                ...           8 years ago
  • 1.4.0                                ...           8 years ago
  • 1.3.0                                ...           8 years ago
  • 1.2.2                                ...           8 years ago
  • 1.2.1                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 1.0.0-rc0                                ...           8 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (8)

Copyright 2013 - present © cnpmjs.org | Home |