1 | /**
|
2 | * @license
|
3 | * Copyright 2013 Palantir Technologies, Inc.
|
4 | *
|
5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | * you may not use this file except in compliance with the License.
|
7 | * You may obtain a copy of the License at
|
8 | *
|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
10 | *
|
11 | * Unless required by applicable law or agreed to in writing, software
|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 | * See the License for the specific language governing permissions and
|
15 | * limitations under the License.
|
16 | */
|
17 | import * as ts from "typescript";
|
18 | import { IDisabledInterval, RuleFailure } from "./rule/rule";
|
19 | export declare function getSourceFile(fileName: string, source: string): ts.SourceFile;
|
20 | /** @deprecated See IDisabledInterval. */
|
21 | export declare function doesIntersect(failure: RuleFailure, disabledIntervals: IDisabledInterval[]): boolean;
|
22 | /**
|
23 | * @returns true if any modifier kinds passed along exist in the given modifiers array
|
24 | *
|
25 | * @deprecated use `hasModifier` from `tsutils`
|
26 | */
|
27 | export declare function hasModifier(modifiers: ts.ModifiersArray | undefined, ...modifierKinds: ts.SyntaxKind[]): boolean;
|
28 | /**
|
29 | * Determines if the appropriate bit in the parent (VariableDeclarationList) is set,
|
30 | * which indicates this is a "let" or "const".
|
31 | *
|
32 | * @deprecated use `isBlockScopedVariableDeclarationList` from `tsutils`
|
33 | */
|
34 | export declare function isBlockScopedVariable(node: ts.VariableDeclaration | ts.VariableStatement): boolean;
|
35 | /** @deprecated use `isBlockScopedVariableDeclarationList` and `getDeclarationOfBindingElement` from `tsutils` */
|
36 | export declare function isBlockScopedBindingElement(node: ts.BindingElement): boolean;
|
37 | /** @deprecated use `getDeclarationOfBindingElement` from `tsutils` */
|
38 | export declare function getBindingElementVariableDeclaration(node: ts.BindingElement): ts.VariableDeclaration | null;
|
39 | /**
|
40 | * Finds a child of a given node with a given kind.
|
41 | * Note: This uses `node.getChildren()`, which does extra parsing work to include tokens.
|
42 | *
|
43 | * @deprecated use `getChildOfKind` from `tsutils`
|
44 | */
|
45 | export declare function childOfKind(node: ts.Node, kind: ts.SyntaxKind): ts.Node | undefined;
|
46 | /**
|
47 | * @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself.
|
48 | *
|
49 | * @deprecated no longer used, use a `while` loop instead
|
50 | */
|
51 | export declare function someAncestor(node: ts.Node, predicate: (n: ts.Node) => boolean): boolean;
|
52 | export declare function ancestorWhere<T extends ts.Node = ts.Node>(node: ts.Node, predicate: ((n: ts.Node) => n is T) | ((n: ts.Node) => boolean)): T | undefined;
|
53 | /** @deprecated use `isBinaryExpression(node) && isAssignmentKind(node.operatorToken.kind)` with functions from `tsutils` */
|
54 | export declare function isAssignment(node: ts.Node): boolean;
|
55 | /**
|
56 | * Bitwise check for node flags.
|
57 | *
|
58 | * @deprecated use `isNodeFlagSet` from `tsutils`
|
59 | */
|
60 | export declare function isNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean;
|
61 | /**
|
62 | * Bitwise check for combined node flags.
|
63 | *
|
64 | * @deprecated no longer used
|
65 | */
|
66 | export declare function isCombinedNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean;
|
67 | /**
|
68 | * Bitwise check for combined modifier flags.
|
69 | *
|
70 | * @deprecated no longer used
|
71 | */
|
72 | export declare function isCombinedModifierFlagSet(node: ts.Declaration, flagToCheck: ts.ModifierFlags): boolean;
|
73 | /**
|
74 | * Bitwise check for type flags.
|
75 | *
|
76 | * @deprecated use `isTypeFlagSet` from `tsutils`
|
77 | */
|
78 | export declare function isTypeFlagSet(type: ts.Type, flagToCheck: ts.TypeFlags): boolean;
|
79 | /**
|
80 | * Bitwise check for symbol flags.
|
81 | *
|
82 | * @deprecated use `isSymbolFlagSet` from `tsutils`
|
83 | */
|
84 | export declare function isSymbolFlagSet(symbol: ts.Symbol, flagToCheck: ts.SymbolFlags): boolean;
|
85 | /**
|
86 | * Bitwise check for object flags.
|
87 | * Does not work with TypeScript 2.0.x
|
88 | *
|
89 | * @deprecated use `isObjectFlagSet` from `tsutils`
|
90 | */
|
91 | export declare function isObjectFlagSet(objectType: ts.ObjectType, flagToCheck: ts.ObjectFlags): boolean;
|
92 | /**
|
93 | * @returns true if decl is a nested module declaration, i.e. represents a segment of a dotted module path.
|
94 | *
|
95 | * @deprecated use `decl.parent!.kind === ts.SyntaxKind.ModuleDeclaration`
|
96 | */
|
97 | export declare function isNestedModuleDeclaration(decl: ts.ModuleDeclaration): boolean;
|
98 | export declare function unwrapParentheses(node: ts.Expression): ts.Expression;
|
99 | /** @deprecated use `isFunctionScopeBoundary` from `tsutils` */
|
100 | export declare function isScopeBoundary(node: ts.Node): boolean;
|
101 | /** @deprecated use `isBlockScopeBoundary` from `tsutils` */
|
102 | export declare function isBlockScopeBoundary(node: ts.Node): boolean;
|
103 | /** @deprecated use `isIterationStatement` from `tsutils` or `typescript` */
|
104 | export declare function isLoop(node: ts.Node): node is ts.IterationStatement;
|
105 | /**
|
106 | * @returns Whether node is a numeric expression.
|
107 | */
|
108 | export declare function isNumeric(node: ts.Expression): boolean;
|
109 | export interface TokenPosition {
|
110 | /** The start of the token including all trivia before it */
|
111 | fullStart: number;
|
112 | /** The start of the token */
|
113 | tokenStart: number;
|
114 | /** The end of the token */
|
115 | end: number;
|
116 | }
|
117 | export declare type ForEachTokenCallback = (fullText: string, kind: ts.SyntaxKind, pos: TokenPosition, parent: ts.Node) => void;
|
118 | export declare type ForEachCommentCallback = (fullText: string, kind: ts.SyntaxKind, pos: TokenPosition) => void;
|
119 | export declare type FilterCallback = (node: ts.Node) => boolean;
|
120 | /**
|
121 | * Iterate over all tokens of `node`
|
122 | *
|
123 | * @description JsDoc comments are treated like regular comments and only visited if `skipTrivia` === false.
|
124 | *
|
125 | * @param node The node whose tokens should be visited
|
126 | * @param skipTrivia If set to false all trivia preceeding `node` or any of its children is included
|
127 | * @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.
|
128 | * @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.
|
129 | *
|
130 | * @deprecated use `forEachToken` or `forEachTokenWithTrivia` from `tsutils`
|
131 | */
|
132 | export declare function forEachToken(node: ts.Node, skipTrivia: boolean, cb: ForEachTokenCallback, filter?: FilterCallback): void;
|
133 | /**
|
134 | * Iterate over all comments owned by `node` or its children
|
135 | *
|
136 | * @deprecated use `forEachComment` from `tsutils`
|
137 | */
|
138 | export declare function forEachComment(node: ts.Node, cb: ForEachCommentCallback): void;
|
139 | /**
|
140 | * Checks if there are any comments between `position` and the next non-trivia token
|
141 | *
|
142 | * @param text The text to scan
|
143 | * @param position The position inside `text` where to start scanning. Make sure that this is a valid start position.
|
144 | * This value is typically obtained from `node.getFullStart()` or `node.getEnd()`
|
145 | */
|
146 | export declare function hasCommentAfterPosition(text: string, position: number): boolean;
|
147 | export interface EqualsKind {
|
148 | isPositive: boolean;
|
149 | isStrict: boolean;
|
150 | }
|
151 | export declare function getEqualsKind(node: ts.BinaryOperatorToken): EqualsKind | undefined;
|
152 | export declare function isStrictNullChecksEnabled(options: ts.CompilerOptions): boolean;
|
153 | export declare function isNegativeNumberLiteral(node: ts.Node): node is ts.PrefixUnaryExpression & {
|
154 | operand: ts.NumericLiteral;
|
155 | };
|
156 | /** Wrapper for compatibility with typescript@<2.3.1 */
|
157 | export declare function isWhiteSpace(ch: number): boolean;
|