All Projects → ajafff → Tsutils

ajafff / Tsutils

Licence: mit
utility functions for working with typescript's AST

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Tsutils

Tatsu
竜 TatSu generates Python parsers from grammars in a variation of EBNF
Stars: ✭ 198 (-17.5%)
Mutual labels:  ast
Vermin
Concurrently detect the minimum Python versions needed to run code
Stars: ✭ 218 (-9.17%)
Mutual labels:  ast
Stdlib
✨ Standard library for JavaScript and Node.js. ✨
Stars: ✭ 2,749 (+1045.42%)
Mutual labels:  utilities
Util
A collection of useful utility functions
Stars: ✭ 201 (-16.25%)
Mutual labels:  utilities
Codejam
Set of handy reusable .NET components that can simplify your daily work and save your time when you copy and paste your favorite helper methods and classes from one project to another
Stars: ✭ 217 (-9.58%)
Mutual labels:  utilities
Mathutilities
A collection of some of the neat math and physics tricks that I've collected over the last few years.
Stars: ✭ 2,815 (+1072.92%)
Mutual labels:  utilities
Bellybutton
Custom Python linting through AST expressions
Stars: ✭ 196 (-18.33%)
Mutual labels:  ast
Cppast.net
CppAst is a .NET library providing a C/C++ parser for header files powered by Clang/libclang with access to the full AST, comments and macros
Stars: ✭ 228 (-5%)
Mutual labels:  ast
Escaya
An blazing fast 100% spec compliant, incremental javascript parser written in Typescript
Stars: ✭ 217 (-9.58%)
Mutual labels:  ast
Devutils App
Offline Toolbox for Developers
Stars: ✭ 2,735 (+1039.58%)
Mutual labels:  utilities
Hexraystoolbox
Hexrays Toolbox - Find code patterns within the Hexrays AST
Stars: ✭ 202 (-15.83%)
Mutual labels:  ast
Westwind.utilities
A general purpose utility and helper library for .NET development
Stars: ✭ 202 (-15.83%)
Mutual labels:  utilities
Ast Query
Tentative to a simple JavaScript AST modification library
Stars: ✭ 221 (-7.92%)
Mutual labels:  ast
Nanoutils
🌊 Tiniest FP-friendly JavaScript utils library
Stars: ✭ 200 (-16.67%)
Mutual labels:  utilities
Funcy
A fancy and practical functional tools
Stars: ✭ 2,690 (+1020.83%)
Mutual labels:  utilities
Cub
The Cub Programming Language
Stars: ✭ 198 (-17.5%)
Mutual labels:  ast
React Monocle
A developer tool to visualize a React application's component hierarchy.
Stars: ✭ 2,440 (+916.67%)
Mutual labels:  ast
Unified
☔️ interface for parsing, inspecting, transforming, and serializing content through syntax trees
Stars: ✭ 3,036 (+1165%)
Mutual labels:  ast
Php Parser
A PHP parser written in PHP
Stars: ✭ 15,101 (+6192.08%)
Mutual labels:  ast
Gitlab Cli
Create a merge request from command line in gitlab
Stars: ✭ 224 (-6.67%)
Mutual labels:  utilities

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 [email protected] 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 [email protected], you should import directly from the submodule for that version:

// all typeguards compatible with [email protected]
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 [email protected] (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';
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].