329 lines
19 KiB
TypeScript
329 lines
19 KiB
TypeScript
/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
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
|
|
|
|
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
and limitations under the License.
|
|
***************************************************************************** */
|
|
|
|
declare module "typescript" {
|
|
const enum Ternary {
|
|
False = 0,
|
|
Maybe = 1,
|
|
True = -1,
|
|
}
|
|
const enum Comparison {
|
|
LessThan = -1,
|
|
EqualTo = 0,
|
|
GreaterThan = 1,
|
|
}
|
|
interface StringSet extends Map<any> {
|
|
}
|
|
function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U;
|
|
function contains<T>(array: T[], value: T): boolean;
|
|
function indexOf<T>(array: T[], value: T): number;
|
|
function countWhere<T>(array: T[], predicate: (x: T) => boolean): number;
|
|
function filter<T>(array: T[], f: (x: T) => boolean): T[];
|
|
function map<T, U>(array: T[], f: (x: T) => U): U[];
|
|
function concatenate<T>(array1: T[], array2: T[]): T[];
|
|
function deduplicate<T>(array: T[]): T[];
|
|
function sum(array: any[], prop: string): number;
|
|
function addRange<T>(to: T[], from: T[]): void;
|
|
/**
|
|
* Returns the last element of an array if non-empty, undefined otherwise.
|
|
*/
|
|
function lastOrUndefined<T>(array: T[]): T;
|
|
function binarySearch(array: number[], value: number): number;
|
|
function hasProperty<T>(map: Map<T>, key: string): boolean;
|
|
function getProperty<T>(map: Map<T>, key: string): T;
|
|
function isEmpty<T>(map: Map<T>): boolean;
|
|
function clone<T>(object: T): T;
|
|
function extend<T>(first: Map<T>, second: Map<T>): Map<T>;
|
|
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
|
|
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
|
|
function lookUp<T>(map: Map<T>, key: string): T;
|
|
function mapToArray<T>(map: Map<T>): T[];
|
|
function copyMap<T>(source: Map<T>, target: Map<T>): void;
|
|
/**
|
|
* Creates a map from the elements of an array.
|
|
*
|
|
* @param array the array of input elements.
|
|
* @param makeKey a function that produces a key for a given element.
|
|
*
|
|
* This function makes no effort to avoid collisions; if any two elements produce
|
|
* the same key with the given 'makeKey' function, then the element with the higher
|
|
* index in the array will be the one associated with the produced key.
|
|
*/
|
|
function arrayToMap<T>(array: T[], makeKey: (value: T) => string): Map<T>;
|
|
var localizedDiagnosticMessages: Map<string>;
|
|
function getLocaleSpecificMessage(message: string): string;
|
|
function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
|
function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
|
function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
|
|
function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain;
|
|
function compareValues<T>(a: T, b: T): Comparison;
|
|
function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison;
|
|
function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
|
|
function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
|
|
function normalizeSlashes(path: string): string;
|
|
function getRootLength(path: string): number;
|
|
var directorySeparator: string;
|
|
function normalizePath(path: string): string;
|
|
function getDirectoryPath(path: string): string;
|
|
function isUrl(path: string): boolean;
|
|
function isRootedDiskPath(path: string): boolean;
|
|
function getNormalizedPathComponents(path: string, currentDirectory: string): string[];
|
|
function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string;
|
|
function getNormalizedPathFromPathComponents(pathComponents: string[]): string;
|
|
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string;
|
|
function getBaseFileName(path: string): string;
|
|
function combinePaths(path1: string, path2: string): string;
|
|
function fileExtensionIs(path: string, extension: string): boolean;
|
|
function removeFileExtension(path: string): string;
|
|
/**
|
|
* Based heavily on the abstract 'Quote' operation from ECMA-262 (24.3.2.2),
|
|
* but augmented for a few select characters.
|
|
* Note that this doesn't actually wrap the input in double quotes.
|
|
*/
|
|
function escapeString(s: string): string;
|
|
function getDefaultLibFileName(options: CompilerOptions): string;
|
|
interface ObjectAllocator {
|
|
getNodeConstructor(kind: SyntaxKind): new () => Node;
|
|
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
|
|
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
|
|
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
|
|
}
|
|
var objectAllocator: ObjectAllocator;
|
|
const enum AssertionLevel {
|
|
None = 0,
|
|
Normal = 1,
|
|
Aggressive = 2,
|
|
VeryAggressive = 3,
|
|
}
|
|
module Debug {
|
|
function shouldAssert(level: AssertionLevel): boolean;
|
|
function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void;
|
|
function fail(message?: string): void;
|
|
}
|
|
}
|
|
declare module "typescript" {
|
|
interface System {
|
|
args: string[];
|
|
newLine: string;
|
|
useCaseSensitiveFileNames: boolean;
|
|
write(s: string): void;
|
|
readFile(fileName: string, encoding?: string): string;
|
|
writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void;
|
|
watchFile?(fileName: string, callback: (fileName: string) => void): FileWatcher;
|
|
resolvePath(path: string): string;
|
|
fileExists(path: string): boolean;
|
|
directoryExists(path: string): boolean;
|
|
createDirectory(directoryName: string): void;
|
|
getExecutingFilePath(): string;
|
|
getCurrentDirectory(): string;
|
|
readDirectory(path: string, extension?: string): string[];
|
|
getMemoryUsage?(): number;
|
|
exit(exitCode?: number): void;
|
|
}
|
|
interface FileWatcher {
|
|
close(): void;
|
|
}
|
|
var sys: System;
|
|
}
|
|
declare module "typescript" {
|
|
interface ReferencePathMatchResult {
|
|
fileReference?: FileReference;
|
|
diagnosticMessage?: DiagnosticMessage;
|
|
isNoDefaultLib?: boolean;
|
|
}
|
|
function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration;
|
|
interface StringSymbolWriter extends SymbolWriter {
|
|
string(): string;
|
|
}
|
|
interface EmitHost extends ScriptReferenceHost {
|
|
getSourceFiles(): SourceFile[];
|
|
getCommonSourceDirectory(): string;
|
|
getCanonicalFileName(fileName: string): string;
|
|
getNewLine(): string;
|
|
writeFile: WriteFileCallback;
|
|
}
|
|
function getSingleLineStringWriter(): StringSymbolWriter;
|
|
function releaseStringWriter(writer: StringSymbolWriter): void;
|
|
function getFullWidth(node: Node): number;
|
|
function containsParseError(node: Node): boolean;
|
|
function getSourceFileOfNode(node: Node): SourceFile;
|
|
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
|
|
function nodePosToString(node: Node): string;
|
|
function getStartPosOfNode(node: Node): number;
|
|
function nodeIsMissing(node: Node): boolean;
|
|
function nodeIsPresent(node: Node): boolean;
|
|
function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number;
|
|
function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string;
|
|
function getTextOfNodeFromSourceText(sourceText: string, node: Node): string;
|
|
function getTextOfNode(node: Node): string;
|
|
function escapeIdentifier(identifier: string): string;
|
|
function unescapeIdentifier(identifier: string): string;
|
|
function makeIdentifierFromModuleName(moduleName: string): string;
|
|
function declarationNameToString(name: DeclarationName): string;
|
|
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
|
|
function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic;
|
|
function getErrorSpanForNode(node: Node): Node;
|
|
function isExternalModule(file: SourceFile): boolean;
|
|
function isDeclarationFile(file: SourceFile): boolean;
|
|
function isConstEnumDeclaration(node: Node): boolean;
|
|
function getCombinedNodeFlags(node: Node): NodeFlags;
|
|
function isConst(node: Node): boolean;
|
|
function isLet(node: Node): boolean;
|
|
function isPrologueDirective(node: Node): boolean;
|
|
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[];
|
|
function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
|
|
var fullTripleSlashReferencePathRegEx: RegExp;
|
|
function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T;
|
|
function isAnyFunction(node: Node): boolean;
|
|
function isFunctionBlock(node: Node): boolean;
|
|
function isObjectLiteralMethod(node: Node): boolean;
|
|
function getContainingFunction(node: Node): FunctionLikeDeclaration;
|
|
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
|
|
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
|
|
function getInvokedExpression(node: CallLikeExpression): Expression;
|
|
function isExpression(node: Node): boolean;
|
|
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
|
|
function isExternalModuleImportEqualsDeclaration(node: Node): boolean;
|
|
function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression;
|
|
function isInternalModuleImportEqualsDeclaration(node: Node): boolean;
|
|
function getExternalModuleName(node: Node): Expression;
|
|
function hasDotDotDotToken(node: Node): boolean;
|
|
function hasQuestionToken(node: Node): boolean;
|
|
function hasRestParameters(s: SignatureDeclaration): boolean;
|
|
function isLiteralKind(kind: SyntaxKind): boolean;
|
|
function isTextualLiteralKind(kind: SyntaxKind): boolean;
|
|
function isTemplateLiteralKind(kind: SyntaxKind): boolean;
|
|
function isBindingPattern(node: Node): boolean;
|
|
function isInAmbientContext(node: Node): boolean;
|
|
function isDeclaration(node: Node): boolean;
|
|
function isStatement(n: Node): boolean;
|
|
function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean;
|
|
function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode;
|
|
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
|
|
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
|
|
function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind): HeritageClause;
|
|
function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile;
|
|
function getAncestor(node: Node, kind: SyntaxKind): Node;
|
|
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
|
|
function isKeyword(token: SyntaxKind): boolean;
|
|
function isTrivia(token: SyntaxKind): boolean;
|
|
/**
|
|
* A declaration has a dynamic name if both of the following are true:
|
|
* 1. The declaration has a computed property name
|
|
* 2. The computed name is *not* expressed as Symbol.<name>, where name
|
|
* is a property of the Symbol constructor that denotes a built in
|
|
* Symbol.
|
|
*/
|
|
function hasDynamicName(declaration: Declaration): boolean;
|
|
/**
|
|
* Checks if the expression is of the form:
|
|
* Symbol.name
|
|
* where Symbol is literally the word "Symbol", and name is any identifierName
|
|
*/
|
|
function isWellKnownSymbolSyntactically(node: Expression): boolean;
|
|
function getPropertyNameForPropertyNameNode(name: DeclarationName): string;
|
|
function getPropertyNameForKnownSymbolName(symbolName: string): string;
|
|
/**
|
|
* Includes the word "Symbol" with unicode escapes
|
|
*/
|
|
function isESSymbolIdentifier(node: Node): boolean;
|
|
function isModifier(token: SyntaxKind): boolean;
|
|
function textSpanEnd(span: TextSpan): number;
|
|
function textSpanIsEmpty(span: TextSpan): boolean;
|
|
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
|
|
function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
|
|
function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
|
|
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
|
|
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
|
|
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
|
|
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
|
|
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
|
|
function createTextSpan(start: number, length: number): TextSpan;
|
|
function createTextSpanFromBounds(start: number, end: number): TextSpan;
|
|
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
|
|
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
|
|
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
|
|
var unchangedTextChangeRange: TextChangeRange;
|
|
/**
|
|
* Called to merge all the changes that occurred across several versions of a script snapshot
|
|
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
|
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
|
*
|
|
* This function will then merge those changes into a single change range valid between V1 and
|
|
* Vn.
|
|
*/
|
|
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
|
}
|
|
declare module "typescript" {
|
|
var optionDeclarations: CommandLineOption[];
|
|
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
|
function readConfigFile(fileName: string): any;
|
|
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
|
|
}
|
|
declare module "typescript" {
|
|
interface ListItemInfo {
|
|
listItemIndex: number;
|
|
list: Node;
|
|
}
|
|
function getEndLinePosition(line: number, sourceFile: SourceFile): number;
|
|
function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number;
|
|
function rangeContainsRange(r1: TextRange, r2: TextRange): boolean;
|
|
function startEndContainsRange(start: number, end: number, range: TextRange): boolean;
|
|
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
|
|
function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean;
|
|
function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean;
|
|
function findListItemInfo(node: Node): ListItemInfo;
|
|
function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node;
|
|
function findContainingList(node: Node): Node;
|
|
function getTouchingWord(sourceFile: SourceFile, position: number): Node;
|
|
function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node;
|
|
/** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */
|
|
function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean): Node;
|
|
/** Returns a token if position is in [start-of-leading-trivia, end) */
|
|
function getTokenAtPosition(sourceFile: SourceFile, position: number): Node;
|
|
/**
|
|
* The token on the left of the position is the token that strictly includes the position
|
|
* or sits to the left of the cursor if it is on a boundary. For example
|
|
*
|
|
* fo|o -> will return foo
|
|
* foo <comment> |bar -> will return foo
|
|
*
|
|
*/
|
|
function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node;
|
|
function findNextToken(previousToken: Node, parent: Node): Node;
|
|
function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node;
|
|
function getNodeModifiers(node: Node): string;
|
|
function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node>;
|
|
function isToken(n: Node): boolean;
|
|
function isComment(kind: SyntaxKind): boolean;
|
|
function isPunctuation(kind: SyntaxKind): boolean;
|
|
function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean;
|
|
function compareDataObjects(dst: any, src: any): boolean;
|
|
}
|
|
declare module "typescript" {
|
|
function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean;
|
|
function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart;
|
|
function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart;
|
|
function spacePart(): SymbolDisplayPart;
|
|
function keywordPart(kind: SyntaxKind): SymbolDisplayPart;
|
|
function punctuationPart(kind: SyntaxKind): SymbolDisplayPart;
|
|
function operatorPart(kind: SyntaxKind): SymbolDisplayPart;
|
|
function textPart(text: string): SymbolDisplayPart;
|
|
function lineBreakPart(): SymbolDisplayPart;
|
|
function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[];
|
|
function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[];
|
|
function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[];
|
|
function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[];
|
|
}
|