UNPKG

5.1 kBTypeScriptView Raw
1import * as ts from "typescript";
2import { IDisabledInterval, RuleFailure } from "./rule/rule";
3export declare function getSourceFile(fileName: string, source: string): ts.SourceFile;
4export declare function createCompilerOptions(): ts.CompilerOptions;
5export declare function doesIntersect(failure: RuleFailure, disabledIntervals: IDisabledInterval[]): boolean;
6/** @deprecated use forEachToken instead */
7export declare function scanAllTokens(scanner: ts.Scanner, callback: (s: ts.Scanner) => void): void;
8/**
9 * @returns true if any modifier kinds passed along exist in the given modifiers array
10 */
11export declare function hasModifier(modifiers: ts.ModifiersArray | undefined, ...modifierKinds: ts.SyntaxKind[]): boolean;
12/**
13 * Determines if the appropriate bit in the parent (VariableDeclarationList) is set,
14 * which indicates this is a "let" or "const".
15 */
16export declare function isBlockScopedVariable(node: ts.VariableDeclaration | ts.VariableStatement): boolean;
17export declare function isBlockScopedBindingElement(node: ts.BindingElement): boolean;
18export declare function getBindingElementVariableDeclaration(node: ts.BindingElement): ts.VariableDeclaration | null;
19/**
20 * Finds a child of a given node with a given kind.
21 * Note: This uses `node.getChildren()`, which does extra parsing work to include tokens.
22 */
23export declare function childOfKind(node: ts.Node, kind: ts.SyntaxKind): ts.Node | undefined;
24/**
25 * @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself.
26 */
27export declare function someAncestor(node: ts.Node, predicate: (n: ts.Node) => boolean): boolean;
28export declare function isAssignment(node: ts.Node): boolean;
29/**
30 * Bitwise check for node flags.
31 */
32export declare function isNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean;
33/**
34 * Bitwise check for combined node flags.
35 */
36export declare function isCombinedNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean;
37/**
38 * Bitwise check for combined modifier flags.
39 */
40export declare function isCombinedModifierFlagSet(node: ts.Node, flagToCheck: ts.ModifierFlags): boolean;
41/**
42 * Bitwise check for type flags.
43 */
44export declare function isTypeFlagSet(type: ts.Type, flagToCheck: ts.TypeFlags): boolean;
45/**
46 * Bitwise check for symbol flags.
47 */
48export declare function isSymbolFlagSet(symbol: ts.Symbol, flagToCheck: ts.SymbolFlags): boolean;
49/**
50 * Bitwise check for object flags.
51 * Does not work with TypeScript 2.0.x
52 */
53export declare function isObjectFlagSet(objectType: ts.ObjectType, flagToCheck: ts.ObjectFlags): boolean;
54/**
55 * @returns true if decl is a nested module declaration, i.e. represents a segment of a dotted module path.
56 */
57export declare function isNestedModuleDeclaration(decl: ts.ModuleDeclaration): boolean;
58export declare function unwrapParentheses(node: ts.Expression): ts.Expression;
59export declare function isScopeBoundary(node: ts.Node): boolean;
60export declare function isBlockScopeBoundary(node: ts.Node): boolean;
61export declare function isLoop(node: ts.Node): node is ts.IterationStatement;
62export interface TokenPosition {
63 /** The start of the token including all trivia before it */
64 fullStart: number;
65 /** The start of the token */
66 tokenStart: number;
67 /** The end of the token */
68 end: number;
69}
70export declare type ForEachTokenCallback = (fullText: string, kind: ts.SyntaxKind, pos: TokenPosition, parent: ts.Node) => void;
71export declare type ForEachCommentCallback = (fullText: string, kind: ts.SyntaxKind, pos: TokenPosition) => void;
72export declare type FilterCallback = (node: ts.Node) => boolean;
73/**
74 * Iterate over all tokens of `node`
75 *
76 * @description JsDoc comments are treated like regular comments and only visited if `skipTrivia` === false.
77 *
78 * @param node The node whose tokens should be visited
79 * @param skipTrivia If set to false all trivia preceeding `node` or any of its children is included
80 * @param cb Is called for every token of `node`. It gets the full text of the SourceFile and the position of the token within that text.
81 * @param filter If provided, will be called for every Node and Token found. If it returns false `cb` will not be called for this subtree.
82 */
83export declare function forEachToken(node: ts.Node, skipTrivia: boolean, cb: ForEachTokenCallback, filter?: FilterCallback): void;
84/** Iterate over all comments owned by `node` or its children */
85export declare function forEachComment(node: ts.Node, cb: ForEachCommentCallback): void;
86/**
87 * Checks if there are any comments between `position` and the next non-trivia token
88 *
89 * @param text The text to scan
90 * @param position The position inside `text` where to start scanning. Make sure that this is a valid start position.
91 * This value is typically obtained from `node.getFullStart()` or `node.getEnd()`
92 */
93export declare function hasCommentAfterPosition(text: string, position: number): boolean;
94export interface EqualsKind {
95 isPositive: boolean;
96 isStrict: boolean;
97}
98export declare function getEqualsKind(node: ts.BinaryOperatorToken): EqualsKind | undefined;