/*! ***************************************************************************** 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 ts { const enum Ternary { False = 0, Maybe = 1, True = -1, } const enum Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1, } interface StringSet extends Map { } function forEach(array: T[], callback: (element: T, index: number) => U): U; function contains(array: T[], value: T): boolean; function indexOf(array: T[], value: T): number; function countWhere(array: T[], predicate: (x: T) => boolean): number; function filter(array: T[], f: (x: T) => boolean): T[]; function map(array: T[], f: (x: T) => U): U[]; function concatenate(array1: T[], array2: T[]): T[]; function deduplicate(array: T[]): T[]; function sum(array: any[], prop: string): number; function addRange(to: T[], from: T[]): void; /** * Returns the last element of an array if non-empty, undefined otherwise. */ function lastOrUndefined(array: T[]): T; function binarySearch(array: number[], value: number): number; function reduceLeft(array: T[], f: (a: T, x: T) => T): T; function reduceLeft(array: T[], f: (a: U, x: T) => U, initial: U): U; function reduceRight(array: T[], f: (a: T, x: T) => T): T; function reduceRight(array: T[], f: (a: U, x: T) => U, initial: U): U; function hasProperty(map: Map, key: string): boolean; function getProperty(map: Map, key: string): T; function isEmpty(map: Map): boolean; function clone(object: T): T; function extend(first: Map, second: Map): Map; function forEachValue(map: Map, callback: (value: T) => U): U; function forEachKey(map: Map, callback: (key: string) => U): U; function lookUp(map: Map, key: string): T; function copyMap(source: Map, target: Map): 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(array: T[], makeKey: (value: T) => string): Map; let localizedDiagnosticMessages: Map; 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(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; let 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; 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; } let 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 ts { 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 ts { interface ReferencePathMatchResult { fileReference?: FileReference; diagnosticMessage?: DiagnosticMessage; isNoDefaultLib?: boolean; } interface SynthesizedNode extends Node { leadingCommentRanges?: CommentRange[]; trailingCommentRanges?: CommentRange[]; startsOnNewLine: 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 isBlockOrCatchScoped(declaration: Declaration): boolean; function getEnclosingBlockScopeContainer(node: Node): Node; function isCatchClauseVariableDeclaration(declaration: Declaration): boolean; 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(sourceFile: SourceFile, node: Node): TextSpan; 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[]; let fullTripleSlashReferencePathRegEx: RegExp; function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; function isFunctionLike(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 nodeCanBeDecorated(node: Node): boolean; function nodeIsDecorated(node: Node): boolean; function childIsDecorated(node: Node): boolean; function nodeOrChildIsDecorated(node: Node): boolean; 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 isClassElement(n: Node): boolean; function isDeclarationName(name: Node): boolean; function isAliasSymbolDeclaration(node: Node): boolean; function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode; function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray; function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; function getHeritageClause(clauses: NodeArray, 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., 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; let 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; function nodeStartsNewLexicalEnvironment(n: Node): boolean; function nodeIsSynthesized(node: Node): boolean; function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node; /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s: string): string; function escapeNonAsciiCharacters(s: string): string; interface EmitTextWriter { write(s: string): void; writeTextOfNode(sourceFile: SourceFile, node: Node): void; writeLine(): void; increaseIndent(): void; decreaseIndent(): void; getText(): string; rawWrite(s: string): void; writeLiteral(s: string): void; getTextPos(): number; getLine(): number; getColumn(): number; getIndent(): number; } function getIndentString(level: number): string; function getIndentSize(): number; function createTextWriter(newLine: String): EmitTextWriter; function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void; function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration; function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean; function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): { firstAccessor: AccessorDeclaration; secondAccessor: AccessorDeclaration; getAccessor: AccessorDeclaration; setAccessor: AccessorDeclaration; }; function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void; function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void; function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void; } declare module ts { var optionDeclarations: CommandLineOption[]; function parseCommandLine(commandLine: string[]): ParsedCommandLine; function readConfigFile(fileName: string): any; function parseConfigFile(json: any, basePath?: string): ParsedCommandLine; } declare module ts { 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 positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; function findListItemInfo(node: Node): ListItemInfo; function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; 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 |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; function isToken(n: Node): boolean; function isWord(kind: SyntaxKind): boolean; function isComment(kind: SyntaxKind): boolean; function isPunctuation(kind: SyntaxKind): boolean; function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; function isAccessibilityModifier(kind: SyntaxKind): boolean; function compareDataObjects(dst: any, src: any): boolean; } declare module ts { 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 textOrKeywordPart(text: string): 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[]; }