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