Update .bashrc
[dotfiles/.git] / util / util.d.ts
1 import * as ts from 'typescript';
2 import { NodeWrap } from './convert-ast';
3 export declare function getChildOfKind<T extends ts.SyntaxKind>(node: ts.Node, kind: T, sourceFile?: ts.SourceFile): ts.Token<T> | undefined;
4 export declare function isTokenKind(kind: ts.SyntaxKind): boolean;
5 export declare function isNodeKind(kind: ts.SyntaxKind): boolean;
6 export declare function isAssignmentKind(kind: ts.SyntaxKind): boolean;
7 export declare function isTypeNodeKind(kind: ts.SyntaxKind): boolean;
8 export declare function isJsDocKind(kind: ts.SyntaxKind): boolean;
9 export declare function isKeywordKind(kind: ts.SyntaxKind): boolean;
10 export declare function isThisParameter(parameter: ts.ParameterDeclaration): boolean;
11 export declare function getModifier(node: ts.Node, kind: ts.Modifier['kind']): ts.Modifier | undefined;
12 export declare function hasModifier(modifiers: ts.ModifiersArray | undefined, ...kinds: Array<ts.Modifier['kind']>): boolean;
13 export declare function isParameterProperty(node: ts.ParameterDeclaration): boolean;
14 export declare function hasAccessModifier(node: ts.ClassElement | ts.ParameterDeclaration): boolean;
15 export declare const isNodeFlagSet: (node: ts.Node, flag: ts.NodeFlags) => boolean;
16 export declare const isTypeFlagSet: (type: ts.Type, flag: ts.TypeFlags) => boolean;
17 export declare const isSymbolFlagSet: (symbol: ts.Symbol, flag: ts.SymbolFlags) => boolean;
18 export declare function isObjectFlagSet(objectType: ts.ObjectType, flag: ts.ObjectFlags): boolean;
19 export declare function isModifierFlagSet(node: ts.Node, flag: ts.ModifierFlags): boolean;
20 export declare function getPreviousStatement(statement: ts.Statement): ts.Statement | undefined;
21 export declare function getNextStatement(statement: ts.Statement): ts.Statement | undefined;
22 export declare function getPreviousToken(node: ts.Node, sourceFile?: ts.SourceFile): ts.Node | undefined;
23 export declare function getNextToken(node: ts.Node, sourceFile?: ts.SourceFile): ts.Node | undefined;
24 export declare function getTokenAtPosition(parent: ts.Node, pos: number, sourceFile?: ts.SourceFile, allowJsDoc?: boolean): ts.Node | undefined;
25 export declare function getCommentAtPosition(sourceFile: ts.SourceFile, pos: number, parent?: ts.Node): ts.CommentRange | undefined;
26 export declare function isPositionInComment(sourceFile: ts.SourceFile, pos: number, parent?: ts.Node): boolean;
27 export declare function commentText(sourceText: string, comment: ts.CommentRange): string;
28 export declare function getWrappedNodeAtPosition(wrap: NodeWrap, pos: number): NodeWrap | undefined;
29 export declare function getPropertyName(propertyName: ts.PropertyName): string | undefined;
30 export declare function forEachDestructuringIdentifier<T>(pattern: ts.BindingPattern, fn: (element: ts.BindingElement & {
31     name: ts.Identifier;
32 }) => T): T | undefined;
33 export declare function forEachDeclaredVariable<T>(declarationList: ts.VariableDeclarationList, cb: (element: (ts.VariableDeclaration | ts.BindingElement) & {
34     name: ts.Identifier;
35 }) => T): T | undefined;
36 export declare enum VariableDeclarationKind {
37     Var = 0,
38     Let = 1,
39     Const = 2
40 }
41 export declare function getVariableDeclarationKind(declarationList: ts.VariableDeclarationList): VariableDeclarationKind;
42 export declare function isBlockScopedVariableDeclarationList(declarationList: ts.VariableDeclarationList): boolean;
43 export declare function isBlockScopedVariableDeclaration(declaration: ts.VariableDeclaration): boolean;
44 export declare function isBlockScopedDeclarationStatement(statement: ts.Statement): statement is ts.DeclarationStatement;
45 export declare function isInSingleStatementContext(statement: ts.Statement): boolean;
46 export declare enum ScopeBoundary {
47     None = 0,
48     Function = 1,
49     Block = 2,
50     Type = 4,
51     ConditionalType = 8
52 }
53 export declare enum ScopeBoundarySelector {
54     Function = 1,
55     Block = 3,
56     Type = 7,
57     InferType = 8
58 }
59 export declare function isScopeBoundary(node: ts.Node): ScopeBoundary;
60 export declare function isTypeScopeBoundary(node: ts.Node): ScopeBoundary;
61 export declare function isFunctionScopeBoundary(node: ts.Node): ScopeBoundary;
62 export declare function isBlockScopeBoundary(node: ts.Node): ScopeBoundary;
63 export declare function hasOwnThisReference(node: ts.Node): boolean;
64 export declare function isFunctionWithBody(node: ts.Node): node is ts.FunctionLikeDeclaration & {
65     body: {};
66 };
67 export declare function forEachToken(node: ts.Node, cb: (node: ts.Node) => void, sourceFile?: ts.SourceFile): void;
68 export declare type ForEachTokenCallback = (fullText: string, kind: ts.SyntaxKind, range: ts.TextRange, parent: ts.Node) => void;
69 export declare function forEachTokenWithTrivia(node: ts.Node, cb: ForEachTokenCallback, sourceFile?: ts.SourceFile): void;
70 export declare type ForEachCommentCallback = (fullText: string, comment: ts.CommentRange) => void;
71 export declare function forEachComment(node: ts.Node, cb: ForEachCommentCallback, sourceFile?: ts.SourceFile): void;
72 export interface LineRange extends ts.TextRange {
73     contentLength: number;
74 }
75 export declare function getLineRanges(sourceFile: ts.SourceFile): LineRange[];
76 export declare function getLineBreakStyle(sourceFile: ts.SourceFile): "\n" | "\r\n";
77 export declare function isValidIdentifier(text: string, languageVersion?: ts.ScriptTarget): boolean;
78 export declare function isValidPropertyAccess(text: string, languageVersion?: ts.ScriptTarget): boolean;
79 export declare function isValidPropertyName(text: string, languageVersion?: ts.ScriptTarget): boolean;
80 export declare function isValidNumericLiteral(text: string, languageVersion?: ts.ScriptTarget): boolean;
81 export declare function isValidJsxIdentifier(text: string, languageVersion?: ts.ScriptTarget): boolean;
82 export declare function isNumericPropertyName(name: string | ts.__String): boolean;
83 export declare function isSameLine(sourceFile: ts.SourceFile, pos1: number, pos2: number): boolean;
84 export declare enum SideEffectOptions {
85     None = 0,
86     TaggedTemplate = 1,
87     Constructor = 2,
88     JsxElement = 4
89 }
90 export declare function hasSideEffects(node: ts.Expression, options?: SideEffectOptions): boolean;
91 export declare function getDeclarationOfBindingElement(node: ts.BindingElement): ts.VariableDeclaration | ts.ParameterDeclaration;
92 export declare function isExpressionValueUsed(node: ts.Expression): boolean;
93 export declare enum AccessKind {
94     None = 0,
95     Read = 1,
96     Write = 2,
97     Delete = 4,
98     ReadWrite = 3,
99     Modification = 6
100 }
101 export declare function getAccessKind(node: ts.Node): AccessKind;
102 export declare function isReassignmentTarget(node: ts.Expression): boolean;
103 export declare function canHaveJsDoc(node: ts.Node): node is ts.HasJSDoc;
104 export declare function getJsDoc(node: ts.Node, sourceFile?: ts.SourceFile): ts.JSDoc[];
105 export declare function parseJsDocOfNode(node: ts.Node, considerTrailingComments?: boolean, sourceFile?: ts.SourceFile): ts.JSDoc[];
106 export declare enum ImportKind {
107     ImportDeclaration = 1,
108     ImportEquals = 2,
109     ExportFrom = 4,
110     DynamicImport = 8,
111     Require = 16,
112     ImportType = 32,
113     All = 63,
114     AllImports = 59,
115     AllStaticImports = 3,
116     AllImportExpressions = 24,
117     AllRequireLike = 18
118 }
119 export declare function findImports(sourceFile: ts.SourceFile, kinds: ImportKind): (ts.StringLiteral | ts.NoSubstitutionTemplateLiteral)[];
120 export declare type ImportLike = ts.ImportDeclaration | (ts.ImportEqualsDeclaration & {
121     moduleReference: ts.ExternalModuleReference;
122 }) | (ts.ExportDeclaration & {
123     moduleSpecifier: {};
124 }) | (ts.CallExpression & {
125     expression: ts.Token<ts.SyntaxKind.ImportKeyword> | (ts.Identifier & {
126         text: 'require';
127     });
128     arguments: [ts.Expression];
129 }) | ts.ImportTypeNode;
130 export declare function findImportLikeNodes(sourceFile: ts.SourceFile, kinds: ImportKind): ImportLike[];
131 export declare function isStatementInAmbientContext(node: ts.Statement): boolean;
132 export declare function isAmbientModuleBlock(node: ts.Node): node is ts.ModuleBlock;
133 export declare function getIIFE(func: ts.FunctionExpression | ts.ArrowFunction): ts.CallExpression | undefined;
134 export declare type StrictCompilerOption = 'noImplicitAny' | 'noImplicitThis' | 'strictNullChecks' | 'strictFunctionTypes' | 'strictPropertyInitialization' | 'alwaysStrict' | 'strictBindCallApply';
135 export declare function isStrictCompilerOptionEnabled(options: ts.CompilerOptions, option: StrictCompilerOption): boolean;
136 export declare type BooleanCompilerOptions = {
137     [K in keyof ts.CompilerOptions]: NonNullable<ts.CompilerOptions[K]> extends boolean ? K : never;
138 } extends {
139     [_ in keyof ts.CompilerOptions]: infer U;
140 } ? U : never;
141 export declare function isCompilerOptionEnabled(options: ts.CompilerOptions, option: BooleanCompilerOptions | 'stripInternal'): boolean;
142 export declare function isAmbientModule(node: ts.ModuleDeclaration): boolean;
143 export declare function getCheckJsDirective(source: string): ts.CheckJsDirective | undefined;
144 export declare function isConstAssertion(node: ts.AssertionExpression): boolean;
145 export declare function isInConstContext(node: ts.Expression): boolean;
146 export declare function isReadonlyAssignmentDeclaration(node: ts.CallExpression, checker: ts.TypeChecker): boolean;
147 export declare function isBindableObjectDefinePropertyCall(node: ts.CallExpression): boolean;
148 export interface WellKnownSymbolLiteral extends ts.PropertyAccessExpression {
149     expression: ts.Identifier & {
150         text: 'Symbol';
151         escapedText: 'symbol';
152     };
153 }
154 export declare function isWellKnownSymbolLiterally(node: ts.Expression): node is WellKnownSymbolLiteral;
155 export interface PropertyName {
156     displayName: string;
157     symbolName: ts.__String;
158 }
159 export declare function getPropertyNameOfWellKnownSymbol(node: WellKnownSymbolLiteral): PropertyName;
160 export interface LateBoundPropertyNames {
161     known: boolean;
162     names: PropertyName[];
163 }
164 export declare function getLateBoundPropertyNames(node: ts.Expression, checker: ts.TypeChecker): LateBoundPropertyNames;
165 export declare function getLateBoundPropertyNamesOfPropertyName(node: ts.PropertyName, checker: ts.TypeChecker): LateBoundPropertyNames;
166 export declare function getSingleLateBoundPropertyNameOfPropertyName(node: ts.PropertyName, checker: ts.TypeChecker): PropertyName | undefined;
167 export declare function unwrapParentheses(node: ts.Expression): ts.Expression;