2015-01-29 20:23:02 +01:00
|
|
|
//// [tests/cases/compiler/APISample_transform.ts] ////
|
|
|
|
|
|
|
|
//// [APISample_transform.ts]
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: This test is a public API sample. The sample sources can be found
|
|
|
|
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function
|
|
|
|
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare var process: any;
|
|
|
|
declare var console: any;
|
|
|
|
declare var fs: any;
|
|
|
|
declare var path: any;
|
2015-02-05 10:47:29 +01:00
|
|
|
declare var os: any;
|
2015-01-29 20:23:02 +01:00
|
|
|
|
|
|
|
import ts = require("typescript");
|
|
|
|
|
|
|
|
function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
|
|
|
// Sources
|
|
|
|
var files = {
|
|
|
|
"file.ts": contents,
|
|
|
|
"lib.d.ts": fs.readFileSync(ts.getDefaultLibFilePath(compilerOptions)).toString()
|
|
|
|
};
|
|
|
|
|
|
|
|
// Generated outputs
|
|
|
|
var outputs = [];
|
|
|
|
|
|
|
|
// Create a compilerHost object to allow the compiler to read and write files
|
|
|
|
var compilerHost = {
|
2015-02-04 01:08:46 +01:00
|
|
|
getSourceFile: (fileName, target) => {
|
|
|
|
return files[fileName] !== undefined ?
|
|
|
|
ts.createSourceFile(fileName, files[fileName], target) : undefined;
|
2015-01-29 20:23:02 +01:00
|
|
|
},
|
|
|
|
writeFile: (name, text, writeByteOrderMark) => {
|
|
|
|
outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
|
|
|
|
},
|
2015-02-04 01:08:46 +01:00
|
|
|
getDefaultLibFileName: () => "lib.d.ts",
|
2015-01-29 20:23:02 +01:00
|
|
|
useCaseSensitiveFileNames: () => false,
|
2015-02-04 01:08:46 +01:00
|
|
|
getCanonicalFileName: (fileName) => fileName,
|
2015-01-29 20:23:02 +01:00
|
|
|
getCurrentDirectory: () => "",
|
|
|
|
getNewLine: () => "\n"
|
|
|
|
};
|
|
|
|
|
|
|
|
// Create a program from inputs
|
|
|
|
var program = ts.createProgram(["file.ts"], compilerOptions, compilerHost);
|
|
|
|
|
|
|
|
// Query for early errors
|
2015-02-05 10:47:29 +01:00
|
|
|
var errors = ts.getPreEmitDiagnostics(program);
|
|
|
|
var emitResult = program.emit();
|
|
|
|
|
|
|
|
errors = errors.concat(emitResult.diagnostics);
|
|
|
|
|
2015-01-29 20:23:02 +01:00
|
|
|
return {
|
|
|
|
outputs: outputs,
|
2015-02-05 10:47:29 +01:00
|
|
|
errors: errors.map(function (e) {
|
2015-02-17 04:55:32 +01:00
|
|
|
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
|
2015-02-05 10:47:29 +01:00
|
|
|
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
|
|
|
})
|
2015-01-29 20:23:02 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calling our transform function using a simple TypeScript variable declarations,
|
|
|
|
// and loading the default library like:
|
|
|
|
var source = "var x: number = 'string'";
|
|
|
|
var result = transform(source);
|
|
|
|
|
|
|
|
console.log(JSON.stringify(result));
|
|
|
|
//// [typescript.d.ts]
|
|
|
|
/*! *****************************************************************************
|
|
|
|
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" {
|
|
|
|
interface Map<T> {
|
|
|
|
[index: string]: T;
|
|
|
|
}
|
|
|
|
interface TextRange {
|
|
|
|
pos: number;
|
|
|
|
end: number;
|
|
|
|
}
|
|
|
|
const enum SyntaxKind {
|
|
|
|
Unknown = 0,
|
|
|
|
EndOfFileToken = 1,
|
|
|
|
SingleLineCommentTrivia = 2,
|
|
|
|
MultiLineCommentTrivia = 3,
|
|
|
|
NewLineTrivia = 4,
|
|
|
|
WhitespaceTrivia = 5,
|
|
|
|
ConflictMarkerTrivia = 6,
|
|
|
|
NumericLiteral = 7,
|
|
|
|
StringLiteral = 8,
|
|
|
|
RegularExpressionLiteral = 9,
|
|
|
|
NoSubstitutionTemplateLiteral = 10,
|
|
|
|
TemplateHead = 11,
|
|
|
|
TemplateMiddle = 12,
|
|
|
|
TemplateTail = 13,
|
|
|
|
OpenBraceToken = 14,
|
|
|
|
CloseBraceToken = 15,
|
|
|
|
OpenParenToken = 16,
|
|
|
|
CloseParenToken = 17,
|
|
|
|
OpenBracketToken = 18,
|
|
|
|
CloseBracketToken = 19,
|
|
|
|
DotToken = 20,
|
|
|
|
DotDotDotToken = 21,
|
|
|
|
SemicolonToken = 22,
|
|
|
|
CommaToken = 23,
|
|
|
|
LessThanToken = 24,
|
|
|
|
GreaterThanToken = 25,
|
|
|
|
LessThanEqualsToken = 26,
|
|
|
|
GreaterThanEqualsToken = 27,
|
|
|
|
EqualsEqualsToken = 28,
|
|
|
|
ExclamationEqualsToken = 29,
|
|
|
|
EqualsEqualsEqualsToken = 30,
|
|
|
|
ExclamationEqualsEqualsToken = 31,
|
|
|
|
EqualsGreaterThanToken = 32,
|
|
|
|
PlusToken = 33,
|
|
|
|
MinusToken = 34,
|
|
|
|
AsteriskToken = 35,
|
|
|
|
SlashToken = 36,
|
|
|
|
PercentToken = 37,
|
|
|
|
PlusPlusToken = 38,
|
|
|
|
MinusMinusToken = 39,
|
|
|
|
LessThanLessThanToken = 40,
|
|
|
|
GreaterThanGreaterThanToken = 41,
|
|
|
|
GreaterThanGreaterThanGreaterThanToken = 42,
|
|
|
|
AmpersandToken = 43,
|
|
|
|
BarToken = 44,
|
|
|
|
CaretToken = 45,
|
|
|
|
ExclamationToken = 46,
|
|
|
|
TildeToken = 47,
|
|
|
|
AmpersandAmpersandToken = 48,
|
|
|
|
BarBarToken = 49,
|
|
|
|
QuestionToken = 50,
|
|
|
|
ColonToken = 51,
|
|
|
|
EqualsToken = 52,
|
|
|
|
PlusEqualsToken = 53,
|
|
|
|
MinusEqualsToken = 54,
|
|
|
|
AsteriskEqualsToken = 55,
|
|
|
|
SlashEqualsToken = 56,
|
|
|
|
PercentEqualsToken = 57,
|
|
|
|
LessThanLessThanEqualsToken = 58,
|
|
|
|
GreaterThanGreaterThanEqualsToken = 59,
|
|
|
|
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
|
|
|
|
AmpersandEqualsToken = 61,
|
|
|
|
BarEqualsToken = 62,
|
|
|
|
CaretEqualsToken = 63,
|
|
|
|
Identifier = 64,
|
|
|
|
BreakKeyword = 65,
|
|
|
|
CaseKeyword = 66,
|
|
|
|
CatchKeyword = 67,
|
|
|
|
ClassKeyword = 68,
|
|
|
|
ConstKeyword = 69,
|
|
|
|
ContinueKeyword = 70,
|
|
|
|
DebuggerKeyword = 71,
|
|
|
|
DefaultKeyword = 72,
|
|
|
|
DeleteKeyword = 73,
|
|
|
|
DoKeyword = 74,
|
|
|
|
ElseKeyword = 75,
|
|
|
|
EnumKeyword = 76,
|
|
|
|
ExportKeyword = 77,
|
|
|
|
ExtendsKeyword = 78,
|
|
|
|
FalseKeyword = 79,
|
|
|
|
FinallyKeyword = 80,
|
|
|
|
ForKeyword = 81,
|
|
|
|
FunctionKeyword = 82,
|
|
|
|
IfKeyword = 83,
|
|
|
|
ImportKeyword = 84,
|
|
|
|
InKeyword = 85,
|
|
|
|
InstanceOfKeyword = 86,
|
|
|
|
NewKeyword = 87,
|
|
|
|
NullKeyword = 88,
|
|
|
|
ReturnKeyword = 89,
|
|
|
|
SuperKeyword = 90,
|
|
|
|
SwitchKeyword = 91,
|
|
|
|
ThisKeyword = 92,
|
|
|
|
ThrowKeyword = 93,
|
|
|
|
TrueKeyword = 94,
|
|
|
|
TryKeyword = 95,
|
|
|
|
TypeOfKeyword = 96,
|
|
|
|
VarKeyword = 97,
|
|
|
|
VoidKeyword = 98,
|
|
|
|
WhileKeyword = 99,
|
|
|
|
WithKeyword = 100,
|
2015-02-08 17:13:15 +01:00
|
|
|
AsKeyword = 101,
|
|
|
|
FromKeyword = 102,
|
|
|
|
ImplementsKeyword = 103,
|
|
|
|
InterfaceKeyword = 104,
|
|
|
|
LetKeyword = 105,
|
|
|
|
PackageKeyword = 106,
|
|
|
|
PrivateKeyword = 107,
|
|
|
|
ProtectedKeyword = 108,
|
|
|
|
PublicKeyword = 109,
|
|
|
|
StaticKeyword = 110,
|
|
|
|
YieldKeyword = 111,
|
|
|
|
AnyKeyword = 112,
|
|
|
|
BooleanKeyword = 113,
|
|
|
|
ConstructorKeyword = 114,
|
|
|
|
DeclareKeyword = 115,
|
|
|
|
GetKeyword = 116,
|
|
|
|
ModuleKeyword = 117,
|
|
|
|
RequireKeyword = 118,
|
|
|
|
NumberKeyword = 119,
|
|
|
|
SetKeyword = 120,
|
|
|
|
StringKeyword = 121,
|
2015-02-23 20:15:56 +01:00
|
|
|
SymbolKeyword = 122,
|
|
|
|
TypeKeyword = 123,
|
|
|
|
OfKeyword = 124,
|
|
|
|
QualifiedName = 125,
|
|
|
|
ComputedPropertyName = 126,
|
|
|
|
TypeParameter = 127,
|
|
|
|
Parameter = 128,
|
|
|
|
PropertySignature = 129,
|
|
|
|
PropertyDeclaration = 130,
|
|
|
|
MethodSignature = 131,
|
|
|
|
MethodDeclaration = 132,
|
|
|
|
Constructor = 133,
|
|
|
|
GetAccessor = 134,
|
|
|
|
SetAccessor = 135,
|
|
|
|
CallSignature = 136,
|
|
|
|
ConstructSignature = 137,
|
|
|
|
IndexSignature = 138,
|
|
|
|
TypeReference = 139,
|
|
|
|
FunctionType = 140,
|
|
|
|
ConstructorType = 141,
|
|
|
|
TypeQuery = 142,
|
|
|
|
TypeLiteral = 143,
|
|
|
|
ArrayType = 144,
|
|
|
|
TupleType = 145,
|
|
|
|
UnionType = 146,
|
|
|
|
ParenthesizedType = 147,
|
|
|
|
ObjectBindingPattern = 148,
|
|
|
|
ArrayBindingPattern = 149,
|
|
|
|
BindingElement = 150,
|
|
|
|
ArrayLiteralExpression = 151,
|
|
|
|
ObjectLiteralExpression = 152,
|
|
|
|
PropertyAccessExpression = 153,
|
|
|
|
ElementAccessExpression = 154,
|
|
|
|
CallExpression = 155,
|
|
|
|
NewExpression = 156,
|
|
|
|
TaggedTemplateExpression = 157,
|
|
|
|
TypeAssertionExpression = 158,
|
|
|
|
ParenthesizedExpression = 159,
|
|
|
|
FunctionExpression = 160,
|
|
|
|
ArrowFunction = 161,
|
|
|
|
DeleteExpression = 162,
|
|
|
|
TypeOfExpression = 163,
|
|
|
|
VoidExpression = 164,
|
|
|
|
PrefixUnaryExpression = 165,
|
|
|
|
PostfixUnaryExpression = 166,
|
|
|
|
BinaryExpression = 167,
|
|
|
|
ConditionalExpression = 168,
|
|
|
|
TemplateExpression = 169,
|
|
|
|
YieldExpression = 170,
|
|
|
|
SpreadElementExpression = 171,
|
|
|
|
OmittedExpression = 172,
|
|
|
|
TemplateSpan = 173,
|
|
|
|
Block = 174,
|
|
|
|
VariableStatement = 175,
|
|
|
|
EmptyStatement = 176,
|
|
|
|
ExpressionStatement = 177,
|
|
|
|
IfStatement = 178,
|
|
|
|
DoStatement = 179,
|
|
|
|
WhileStatement = 180,
|
|
|
|
ForStatement = 181,
|
|
|
|
ForInStatement = 182,
|
|
|
|
ForOfStatement = 183,
|
|
|
|
ContinueStatement = 184,
|
|
|
|
BreakStatement = 185,
|
|
|
|
ReturnStatement = 186,
|
|
|
|
WithStatement = 187,
|
|
|
|
SwitchStatement = 188,
|
|
|
|
LabeledStatement = 189,
|
|
|
|
ThrowStatement = 190,
|
|
|
|
TryStatement = 191,
|
|
|
|
DebuggerStatement = 192,
|
|
|
|
VariableDeclaration = 193,
|
|
|
|
VariableDeclarationList = 194,
|
|
|
|
FunctionDeclaration = 195,
|
|
|
|
ClassDeclaration = 196,
|
|
|
|
InterfaceDeclaration = 197,
|
|
|
|
TypeAliasDeclaration = 198,
|
|
|
|
EnumDeclaration = 199,
|
|
|
|
ModuleDeclaration = 200,
|
|
|
|
ModuleBlock = 201,
|
|
|
|
ImportEqualsDeclaration = 202,
|
|
|
|
ImportDeclaration = 203,
|
|
|
|
ImportClause = 204,
|
|
|
|
NamespaceImport = 205,
|
|
|
|
NamedImports = 206,
|
|
|
|
ImportSpecifier = 207,
|
|
|
|
ExportAssignment = 208,
|
|
|
|
ExportDeclaration = 209,
|
|
|
|
NamedExports = 210,
|
|
|
|
ExportSpecifier = 211,
|
|
|
|
ExternalModuleReference = 212,
|
|
|
|
CaseClause = 213,
|
|
|
|
DefaultClause = 214,
|
|
|
|
HeritageClause = 215,
|
|
|
|
CatchClause = 216,
|
|
|
|
PropertyAssignment = 217,
|
|
|
|
ShorthandPropertyAssignment = 218,
|
|
|
|
EnumMember = 219,
|
|
|
|
SourceFile = 220,
|
|
|
|
SyntaxList = 221,
|
|
|
|
Count = 222,
|
2015-01-29 20:23:02 +01:00
|
|
|
FirstAssignment = 52,
|
|
|
|
LastAssignment = 63,
|
|
|
|
FirstReservedWord = 65,
|
|
|
|
LastReservedWord = 100,
|
|
|
|
FirstKeyword = 65,
|
2015-02-23 20:15:56 +01:00
|
|
|
LastKeyword = 124,
|
2015-02-08 17:13:15 +01:00
|
|
|
FirstFutureReservedWord = 103,
|
|
|
|
LastFutureReservedWord = 111,
|
2015-02-23 20:15:56 +01:00
|
|
|
FirstTypeNode = 139,
|
|
|
|
LastTypeNode = 147,
|
2015-01-29 20:23:02 +01:00
|
|
|
FirstPunctuation = 14,
|
|
|
|
LastPunctuation = 63,
|
|
|
|
FirstToken = 0,
|
2015-02-23 20:15:56 +01:00
|
|
|
LastToken = 124,
|
2015-01-29 20:23:02 +01:00
|
|
|
FirstTriviaToken = 2,
|
|
|
|
LastTriviaToken = 6,
|
|
|
|
FirstLiteralToken = 7,
|
|
|
|
LastLiteralToken = 10,
|
|
|
|
FirstTemplateToken = 10,
|
|
|
|
LastTemplateToken = 13,
|
|
|
|
FirstBinaryOperator = 24,
|
|
|
|
LastBinaryOperator = 63,
|
2015-02-23 20:15:56 +01:00
|
|
|
FirstNode = 125,
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
const enum NodeFlags {
|
|
|
|
Export = 1,
|
|
|
|
Ambient = 2,
|
|
|
|
Public = 16,
|
|
|
|
Private = 32,
|
|
|
|
Protected = 64,
|
|
|
|
Static = 128,
|
|
|
|
MultiLine = 256,
|
|
|
|
Synthetic = 512,
|
|
|
|
DeclarationFile = 1024,
|
|
|
|
Let = 2048,
|
|
|
|
Const = 4096,
|
|
|
|
OctalLiteral = 8192,
|
|
|
|
Modifier = 243,
|
|
|
|
AccessibilityModifier = 112,
|
|
|
|
BlockScoped = 6144,
|
|
|
|
}
|
|
|
|
const enum ParserContextFlags {
|
|
|
|
StrictMode = 1,
|
|
|
|
DisallowIn = 2,
|
|
|
|
Yield = 4,
|
|
|
|
GeneratorParameter = 8,
|
|
|
|
ThisNodeHasError = 16,
|
|
|
|
ParserGeneratedFlags = 31,
|
|
|
|
ThisNodeOrAnySubNodesHasError = 32,
|
|
|
|
HasAggregatedChildData = 64,
|
|
|
|
}
|
2015-01-31 01:29:20 +01:00
|
|
|
const enum RelationComparisonResult {
|
|
|
|
Succeeded = 1,
|
|
|
|
Failed = 2,
|
|
|
|
FailedAndReported = 3,
|
|
|
|
}
|
2015-01-29 20:23:02 +01:00
|
|
|
interface Node extends TextRange {
|
|
|
|
kind: SyntaxKind;
|
|
|
|
flags: NodeFlags;
|
|
|
|
parserContextFlags?: ParserContextFlags;
|
2015-02-15 17:30:39 +01:00
|
|
|
modifiers?: ModifiersArray;
|
2015-01-29 20:23:02 +01:00
|
|
|
id?: number;
|
|
|
|
parent?: Node;
|
|
|
|
symbol?: Symbol;
|
|
|
|
locals?: SymbolTable;
|
|
|
|
nextContainer?: Node;
|
|
|
|
localSymbol?: Symbol;
|
|
|
|
}
|
|
|
|
interface NodeArray<T> extends Array<T>, TextRange {
|
|
|
|
hasTrailingComma?: boolean;
|
|
|
|
}
|
|
|
|
interface ModifiersArray extends NodeArray<Node> {
|
|
|
|
flags: number;
|
|
|
|
}
|
|
|
|
interface Identifier extends PrimaryExpression {
|
|
|
|
text: string;
|
|
|
|
}
|
|
|
|
interface QualifiedName extends Node {
|
|
|
|
left: EntityName;
|
|
|
|
right: Identifier;
|
|
|
|
}
|
|
|
|
type EntityName = Identifier | QualifiedName;
|
|
|
|
type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern;
|
|
|
|
interface Declaration extends Node {
|
|
|
|
_declarationBrand: any;
|
|
|
|
name?: DeclarationName;
|
|
|
|
}
|
|
|
|
interface ComputedPropertyName extends Node {
|
|
|
|
expression: Expression;
|
|
|
|
}
|
|
|
|
interface TypeParameterDeclaration extends Declaration {
|
|
|
|
name: Identifier;
|
|
|
|
constraint?: TypeNode;
|
|
|
|
expression?: Expression;
|
|
|
|
}
|
|
|
|
interface SignatureDeclaration extends Declaration {
|
|
|
|
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
|
|
|
parameters: NodeArray<ParameterDeclaration>;
|
|
|
|
type?: TypeNode;
|
|
|
|
}
|
|
|
|
interface VariableDeclaration extends Declaration {
|
|
|
|
parent?: VariableDeclarationList;
|
|
|
|
name: Identifier | BindingPattern;
|
|
|
|
type?: TypeNode;
|
|
|
|
initializer?: Expression;
|
|
|
|
}
|
|
|
|
interface VariableDeclarationList extends Node {
|
|
|
|
declarations: NodeArray<VariableDeclaration>;
|
|
|
|
}
|
|
|
|
interface ParameterDeclaration extends Declaration {
|
|
|
|
dotDotDotToken?: Node;
|
|
|
|
name: Identifier | BindingPattern;
|
|
|
|
questionToken?: Node;
|
|
|
|
type?: TypeNode;
|
|
|
|
initializer?: Expression;
|
|
|
|
}
|
|
|
|
interface BindingElement extends Declaration {
|
|
|
|
propertyName?: Identifier;
|
|
|
|
dotDotDotToken?: Node;
|
|
|
|
name: Identifier | BindingPattern;
|
|
|
|
initializer?: Expression;
|
|
|
|
}
|
|
|
|
interface PropertyDeclaration extends Declaration, ClassElement {
|
|
|
|
name: DeclarationName;
|
|
|
|
questionToken?: Node;
|
|
|
|
type?: TypeNode;
|
|
|
|
initializer?: Expression;
|
|
|
|
}
|
|
|
|
interface ObjectLiteralElement extends Declaration {
|
|
|
|
_objectLiteralBrandBrand: any;
|
|
|
|
}
|
|
|
|
interface PropertyAssignment extends ObjectLiteralElement {
|
|
|
|
_propertyAssignmentBrand: any;
|
|
|
|
name: DeclarationName;
|
|
|
|
questionToken?: Node;
|
|
|
|
initializer: Expression;
|
|
|
|
}
|
|
|
|
interface ShorthandPropertyAssignment extends ObjectLiteralElement {
|
|
|
|
name: Identifier;
|
|
|
|
questionToken?: Node;
|
|
|
|
}
|
|
|
|
interface VariableLikeDeclaration extends Declaration {
|
|
|
|
propertyName?: Identifier;
|
|
|
|
dotDotDotToken?: Node;
|
|
|
|
name: DeclarationName;
|
|
|
|
questionToken?: Node;
|
|
|
|
type?: TypeNode;
|
|
|
|
initializer?: Expression;
|
|
|
|
}
|
|
|
|
interface BindingPattern extends Node {
|
|
|
|
elements: NodeArray<BindingElement>;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Several node kinds share function-like features such as a signature,
|
|
|
|
* a name, and a body. These nodes should extend FunctionLikeDeclaration.
|
|
|
|
* Examples:
|
|
|
|
* FunctionDeclaration
|
|
|
|
* MethodDeclaration
|
|
|
|
* AccessorDeclaration
|
|
|
|
*/
|
|
|
|
interface FunctionLikeDeclaration extends SignatureDeclaration {
|
|
|
|
_functionLikeDeclarationBrand: any;
|
|
|
|
asteriskToken?: Node;
|
|
|
|
questionToken?: Node;
|
|
|
|
body?: Block | Expression;
|
|
|
|
}
|
|
|
|
interface FunctionDeclaration extends FunctionLikeDeclaration, Statement {
|
|
|
|
name: Identifier;
|
|
|
|
body?: Block;
|
|
|
|
}
|
|
|
|
interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
|
|
|
body?: Block;
|
|
|
|
}
|
|
|
|
interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement {
|
|
|
|
body?: Block;
|
|
|
|
}
|
|
|
|
interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
|
|
|
_accessorDeclarationBrand: any;
|
|
|
|
body: Block;
|
|
|
|
}
|
|
|
|
interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement {
|
|
|
|
_indexSignatureDeclarationBrand: any;
|
|
|
|
}
|
|
|
|
interface TypeNode extends Node {
|
|
|
|
_typeNodeBrand: any;
|
|
|
|
}
|
|
|
|
interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration {
|
|
|
|
_functionOrConstructorTypeNodeBrand: any;
|
|
|
|
}
|
|
|
|
interface TypeReferenceNode extends TypeNode {
|
|
|
|
typeName: EntityName;
|
|
|
|
typeArguments?: NodeArray<TypeNode>;
|
|
|
|
}
|
|
|
|
interface TypeQueryNode extends TypeNode {
|
|
|
|
exprName: EntityName;
|
|
|
|
}
|
|
|
|
interface TypeLiteralNode extends TypeNode, Declaration {
|
|
|
|
members: NodeArray<Node>;
|
|
|
|
}
|
|
|
|
interface ArrayTypeNode extends TypeNode {
|
|
|
|
elementType: TypeNode;
|
|
|
|
}
|
|
|
|
interface TupleTypeNode extends TypeNode {
|
|
|
|
elementTypes: NodeArray<TypeNode>;
|
|
|
|
}
|
|
|
|
interface UnionTypeNode extends TypeNode {
|
|
|
|
types: NodeArray<TypeNode>;
|
|
|
|
}
|
|
|
|
interface ParenthesizedTypeNode extends TypeNode {
|
|
|
|
type: TypeNode;
|
|
|
|
}
|
|
|
|
interface StringLiteralTypeNode extends LiteralExpression, TypeNode {
|
|
|
|
}
|
|
|
|
interface Expression extends Node {
|
|
|
|
_expressionBrand: any;
|
|
|
|
contextualType?: Type;
|
|
|
|
}
|
|
|
|
interface UnaryExpression extends Expression {
|
|
|
|
_unaryExpressionBrand: any;
|
|
|
|
}
|
|
|
|
interface PrefixUnaryExpression extends UnaryExpression {
|
|
|
|
operator: SyntaxKind;
|
|
|
|
operand: UnaryExpression;
|
|
|
|
}
|
|
|
|
interface PostfixUnaryExpression extends PostfixExpression {
|
|
|
|
operand: LeftHandSideExpression;
|
|
|
|
operator: SyntaxKind;
|
|
|
|
}
|
|
|
|
interface PostfixExpression extends UnaryExpression {
|
|
|
|
_postfixExpressionBrand: any;
|
|
|
|
}
|
|
|
|
interface LeftHandSideExpression extends PostfixExpression {
|
|
|
|
_leftHandSideExpressionBrand: any;
|
|
|
|
}
|
|
|
|
interface MemberExpression extends LeftHandSideExpression {
|
|
|
|
_memberExpressionBrand: any;
|
|
|
|
}
|
|
|
|
interface PrimaryExpression extends MemberExpression {
|
|
|
|
_primaryExpressionBrand: any;
|
|
|
|
}
|
|
|
|
interface DeleteExpression extends UnaryExpression {
|
|
|
|
expression: UnaryExpression;
|
|
|
|
}
|
|
|
|
interface TypeOfExpression extends UnaryExpression {
|
|
|
|
expression: UnaryExpression;
|
|
|
|
}
|
|
|
|
interface VoidExpression extends UnaryExpression {
|
|
|
|
expression: UnaryExpression;
|
|
|
|
}
|
|
|
|
interface YieldExpression extends Expression {
|
|
|
|
asteriskToken?: Node;
|
|
|
|
expression: Expression;
|
|
|
|
}
|
|
|
|
interface BinaryExpression extends Expression {
|
|
|
|
left: Expression;
|
2015-02-21 03:56:42 +01:00
|
|
|
operatorToken: Node;
|
2015-01-29 20:23:02 +01:00
|
|
|
right: Expression;
|
|
|
|
}
|
|
|
|
interface ConditionalExpression extends Expression {
|
|
|
|
condition: Expression;
|
|
|
|
whenTrue: Expression;
|
|
|
|
whenFalse: Expression;
|
|
|
|
}
|
|
|
|
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration {
|
|
|
|
name?: Identifier;
|
|
|
|
body: Block | Expression;
|
|
|
|
}
|
|
|
|
interface LiteralExpression extends PrimaryExpression {
|
|
|
|
text: string;
|
|
|
|
isUnterminated?: boolean;
|
|
|
|
}
|
|
|
|
interface StringLiteralExpression extends LiteralExpression {
|
|
|
|
_stringLiteralExpressionBrand: any;
|
|
|
|
}
|
|
|
|
interface TemplateExpression extends PrimaryExpression {
|
|
|
|
head: LiteralExpression;
|
|
|
|
templateSpans: NodeArray<TemplateSpan>;
|
|
|
|
}
|
|
|
|
interface TemplateSpan extends Node {
|
|
|
|
expression: Expression;
|
|
|
|
literal: LiteralExpression;
|
|
|
|
}
|
|
|
|
interface ParenthesizedExpression extends PrimaryExpression {
|
|
|
|
expression: Expression;
|
|
|
|
}
|
|
|
|
interface ArrayLiteralExpression extends PrimaryExpression {
|
|
|
|
elements: NodeArray<Expression>;
|
|
|
|
}
|
|
|
|
interface SpreadElementExpression extends Expression {
|
|
|
|
expression: Expression;
|
|
|
|
}
|
|
|
|
interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
|
|
|
|
properties: NodeArray<ObjectLiteralElement>;
|
|
|
|
}
|
|
|
|
interface PropertyAccessExpression extends MemberExpression {
|
|
|
|
expression: LeftHandSideExpression;
|
|
|
|
name: Identifier;
|
|
|
|
}
|
|
|
|
interface ElementAccessExpression extends MemberExpression {
|
|
|
|
expression: LeftHandSideExpression;
|
|
|
|
argumentExpression?: Expression;
|
|
|
|
}
|
|
|
|
interface CallExpression extends LeftHandSideExpression {
|
|
|
|
expression: LeftHandSideExpression;
|
|
|
|
typeArguments?: NodeArray<TypeNode>;
|
|
|
|
arguments: NodeArray<Expression>;
|
|
|
|
}
|
|
|
|
interface NewExpression extends CallExpression, PrimaryExpression {
|
|
|
|
}
|
|
|
|
interface TaggedTemplateExpression extends MemberExpression {
|
|
|
|
tag: LeftHandSideExpression;
|
|
|
|
template: LiteralExpression | TemplateExpression;
|
|
|
|
}
|
|
|
|
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression;
|
|
|
|
interface TypeAssertion extends UnaryExpression {
|
|
|
|
type: TypeNode;
|
|
|
|
expression: UnaryExpression;
|
|
|
|
}
|
|
|
|
interface Statement extends Node, ModuleElement {
|
|
|
|
_statementBrand: any;
|
|
|
|
}
|
|
|
|
interface Block extends Statement {
|
|
|
|
statements: NodeArray<Statement>;
|
|
|
|
}
|
|
|
|
interface VariableStatement extends Statement {
|
|
|
|
declarationList: VariableDeclarationList;
|
|
|
|
}
|
|
|
|
interface ExpressionStatement extends Statement {
|
|
|
|
expression: Expression;
|
|
|
|
}
|
|
|
|
interface IfStatement extends Statement {
|
|
|
|
expression: Expression;
|
|
|
|
thenStatement: Statement;
|
|
|
|
elseStatement?: Statement;
|
|
|
|
}
|
|
|
|
interface IterationStatement extends Statement {
|
|
|
|
statement: Statement;
|
|
|
|
}
|
|
|
|
interface DoStatement extends IterationStatement {
|
|
|
|
expression: Expression;
|
|
|
|
}
|
|
|
|
interface WhileStatement extends IterationStatement {
|
|
|
|
expression: Expression;
|
|
|
|
}
|
|
|
|
interface ForStatement extends IterationStatement {
|
|
|
|
initializer?: VariableDeclarationList | Expression;
|
|
|
|
condition?: Expression;
|
|
|
|
iterator?: Expression;
|
|
|
|
}
|
|
|
|
interface ForInStatement extends IterationStatement {
|
|
|
|
initializer: VariableDeclarationList | Expression;
|
|
|
|
expression: Expression;
|
|
|
|
}
|
2015-02-17 01:33:07 +01:00
|
|
|
interface ForOfStatement extends IterationStatement {
|
|
|
|
initializer: VariableDeclarationList | Expression;
|
|
|
|
expression: Expression;
|
|
|
|
}
|
2015-01-29 20:23:02 +01:00
|
|
|
interface BreakOrContinueStatement extends Statement {
|
|
|
|
label?: Identifier;
|
|
|
|
}
|
|
|
|
interface ReturnStatement extends Statement {
|
|
|
|
expression?: Expression;
|
|
|
|
}
|
|
|
|
interface WithStatement extends Statement {
|
|
|
|
expression: Expression;
|
|
|
|
statement: Statement;
|
|
|
|
}
|
|
|
|
interface SwitchStatement extends Statement {
|
|
|
|
expression: Expression;
|
|
|
|
clauses: NodeArray<CaseOrDefaultClause>;
|
|
|
|
}
|
|
|
|
interface CaseClause extends Node {
|
|
|
|
expression?: Expression;
|
|
|
|
statements: NodeArray<Statement>;
|
|
|
|
}
|
|
|
|
interface DefaultClause extends Node {
|
|
|
|
statements: NodeArray<Statement>;
|
|
|
|
}
|
|
|
|
type CaseOrDefaultClause = CaseClause | DefaultClause;
|
|
|
|
interface LabeledStatement extends Statement {
|
|
|
|
label: Identifier;
|
|
|
|
statement: Statement;
|
|
|
|
}
|
|
|
|
interface ThrowStatement extends Statement {
|
|
|
|
expression: Expression;
|
|
|
|
}
|
|
|
|
interface TryStatement extends Statement {
|
|
|
|
tryBlock: Block;
|
|
|
|
catchClause?: CatchClause;
|
|
|
|
finallyBlock?: Block;
|
|
|
|
}
|
|
|
|
interface CatchClause extends Declaration {
|
|
|
|
name: Identifier;
|
|
|
|
type?: TypeNode;
|
|
|
|
block: Block;
|
|
|
|
}
|
|
|
|
interface ModuleElement extends Node {
|
|
|
|
_moduleElementBrand: any;
|
|
|
|
}
|
|
|
|
interface ClassDeclaration extends Declaration, ModuleElement {
|
|
|
|
name: Identifier;
|
|
|
|
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
|
|
|
heritageClauses?: NodeArray<HeritageClause>;
|
|
|
|
members: NodeArray<ClassElement>;
|
|
|
|
}
|
|
|
|
interface ClassElement extends Declaration {
|
|
|
|
_classElementBrand: any;
|
|
|
|
}
|
|
|
|
interface InterfaceDeclaration extends Declaration, ModuleElement {
|
|
|
|
name: Identifier;
|
|
|
|
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
|
|
|
heritageClauses?: NodeArray<HeritageClause>;
|
|
|
|
members: NodeArray<Declaration>;
|
|
|
|
}
|
|
|
|
interface HeritageClause extends Node {
|
|
|
|
token: SyntaxKind;
|
|
|
|
types?: NodeArray<TypeReferenceNode>;
|
|
|
|
}
|
|
|
|
interface TypeAliasDeclaration extends Declaration, ModuleElement {
|
|
|
|
name: Identifier;
|
|
|
|
type: TypeNode;
|
|
|
|
}
|
|
|
|
interface EnumMember extends Declaration {
|
|
|
|
name: DeclarationName;
|
|
|
|
initializer?: Expression;
|
|
|
|
}
|
|
|
|
interface EnumDeclaration extends Declaration, ModuleElement {
|
|
|
|
name: Identifier;
|
|
|
|
members: NodeArray<EnumMember>;
|
|
|
|
}
|
2015-02-15 17:30:39 +01:00
|
|
|
interface ExportContainer {
|
|
|
|
exportStars?: ExportDeclaration[];
|
|
|
|
}
|
|
|
|
interface ModuleDeclaration extends Declaration, ModuleElement, ExportContainer {
|
2015-01-29 20:23:02 +01:00
|
|
|
name: Identifier | LiteralExpression;
|
|
|
|
body: ModuleBlock | ModuleDeclaration;
|
|
|
|
}
|
|
|
|
interface ModuleBlock extends Node, ModuleElement {
|
|
|
|
statements: NodeArray<ModuleElement>;
|
|
|
|
}
|
2015-02-08 17:13:15 +01:00
|
|
|
interface ImportEqualsDeclaration extends Declaration, ModuleElement {
|
2015-01-29 20:23:02 +01:00
|
|
|
name: Identifier;
|
|
|
|
moduleReference: EntityName | ExternalModuleReference;
|
|
|
|
}
|
|
|
|
interface ExternalModuleReference extends Node {
|
|
|
|
expression?: Expression;
|
|
|
|
}
|
2015-02-08 17:13:15 +01:00
|
|
|
interface ImportDeclaration extends Statement, ModuleElement {
|
|
|
|
importClause?: ImportClause;
|
|
|
|
moduleSpecifier: Expression;
|
|
|
|
}
|
|
|
|
interface ImportClause extends Declaration {
|
|
|
|
name?: Identifier;
|
|
|
|
namedBindings?: NamespaceImport | NamedImports;
|
|
|
|
}
|
|
|
|
interface NamespaceImport extends Declaration {
|
|
|
|
name: Identifier;
|
|
|
|
}
|
2015-02-13 03:05:50 +01:00
|
|
|
interface ExportDeclaration extends Statement, ModuleElement {
|
|
|
|
exportClause?: NamedExports;
|
|
|
|
moduleSpecifier?: Expression;
|
2015-02-08 17:13:15 +01:00
|
|
|
}
|
2015-02-13 03:05:50 +01:00
|
|
|
interface NamedImportsOrExports extends Node {
|
|
|
|
elements: NodeArray<ImportOrExportSpecifier>;
|
|
|
|
}
|
|
|
|
type NamedImports = NamedImportsOrExports;
|
|
|
|
type NamedExports = NamedImportsOrExports;
|
|
|
|
interface ImportOrExportSpecifier extends Declaration {
|
2015-02-08 17:13:15 +01:00
|
|
|
propertyName?: Identifier;
|
|
|
|
name: Identifier;
|
|
|
|
}
|
2015-02-13 03:05:50 +01:00
|
|
|
type ImportSpecifier = ImportOrExportSpecifier;
|
|
|
|
type ExportSpecifier = ImportOrExportSpecifier;
|
2015-01-29 20:23:02 +01:00
|
|
|
interface ExportAssignment extends Statement, ModuleElement {
|
|
|
|
exportName: Identifier;
|
|
|
|
}
|
|
|
|
interface FileReference extends TextRange {
|
2015-02-04 01:08:46 +01:00
|
|
|
fileName: string;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
interface CommentRange extends TextRange {
|
|
|
|
hasTrailingNewLine?: boolean;
|
|
|
|
}
|
2015-02-15 17:30:39 +01:00
|
|
|
interface SourceFile extends Declaration, ExportContainer {
|
2015-01-29 20:23:02 +01:00
|
|
|
statements: NodeArray<ModuleElement>;
|
|
|
|
endOfFileToken: Node;
|
2015-02-04 01:08:46 +01:00
|
|
|
fileName: string;
|
2015-01-29 20:23:02 +01:00
|
|
|
text: string;
|
2015-02-12 18:52:09 +01:00
|
|
|
amdDependencies: {
|
|
|
|
path: string;
|
|
|
|
name: string;
|
|
|
|
}[];
|
2015-01-29 20:23:02 +01:00
|
|
|
amdModuleName: string;
|
|
|
|
referencedFiles: FileReference[];
|
|
|
|
hasNoDefaultLib: boolean;
|
|
|
|
externalModuleIndicator: Node;
|
|
|
|
languageVersion: ScriptTarget;
|
|
|
|
identifiers: Map<string>;
|
|
|
|
}
|
|
|
|
interface ScriptReferenceHost {
|
|
|
|
getCompilerOptions(): CompilerOptions;
|
2015-02-04 01:08:46 +01:00
|
|
|
getSourceFile(fileName: string): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
getCurrentDirectory(): string;
|
|
|
|
}
|
2015-02-05 01:53:14 +01:00
|
|
|
interface WriteFileCallback {
|
|
|
|
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
|
|
|
}
|
2015-01-29 20:23:02 +01:00
|
|
|
interface Program extends ScriptReferenceHost {
|
|
|
|
getSourceFiles(): SourceFile[];
|
2015-02-05 01:53:14 +01:00
|
|
|
/**
|
|
|
|
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
|
|
|
* the javascript and declaration files will be produced for all the files in this program.
|
|
|
|
* If targetSourceFile is specified, then only the javascript and declaration for that
|
|
|
|
* specific file will be generated.
|
|
|
|
*
|
2015-02-05 08:20:26 +01:00
|
|
|
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
2015-02-05 01:53:14 +01:00
|
|
|
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
|
|
|
* will be invoked when writing the javascript and declaration files.
|
|
|
|
*/
|
|
|
|
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
2015-02-05 10:47:29 +01:00
|
|
|
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
2015-01-29 20:23:02 +01:00
|
|
|
getGlobalDiagnostics(): Diagnostic[];
|
2015-02-05 10:47:29 +01:00
|
|
|
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
|
|
|
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
2015-02-05 01:11:38 +01:00
|
|
|
getTypeChecker(): TypeChecker;
|
2015-01-29 20:23:02 +01:00
|
|
|
getCommonSourceDirectory(): string;
|
|
|
|
}
|
|
|
|
interface SourceMapSpan {
|
|
|
|
emittedLine: number;
|
|
|
|
emittedColumn: number;
|
|
|
|
sourceLine: number;
|
|
|
|
sourceColumn: number;
|
|
|
|
nameIndex?: number;
|
|
|
|
sourceIndex: number;
|
|
|
|
}
|
|
|
|
interface SourceMapData {
|
|
|
|
sourceMapFilePath: string;
|
|
|
|
jsSourceMappingURL: string;
|
|
|
|
sourceMapFile: string;
|
|
|
|
sourceMapSourceRoot: string;
|
|
|
|
sourceMapSources: string[];
|
|
|
|
inputSourceFileNames: string[];
|
|
|
|
sourceMapNames?: string[];
|
|
|
|
sourceMapMappings: string;
|
|
|
|
sourceMapDecodedMappings: SourceMapSpan[];
|
|
|
|
}
|
2015-02-06 00:50:18 +01:00
|
|
|
enum ExitStatus {
|
|
|
|
Success = 0,
|
|
|
|
DiagnosticsPresent_OutputsSkipped = 1,
|
|
|
|
DiagnosticsPresent_OutputsGenerated = 2,
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
interface EmitResult {
|
2015-02-06 00:50:18 +01:00
|
|
|
emitSkipped: boolean;
|
2015-01-29 20:23:02 +01:00
|
|
|
diagnostics: Diagnostic[];
|
|
|
|
sourceMaps: SourceMapData[];
|
|
|
|
}
|
|
|
|
interface TypeCheckerHost {
|
|
|
|
getCompilerOptions(): CompilerOptions;
|
|
|
|
getSourceFiles(): SourceFile[];
|
2015-02-04 01:08:46 +01:00
|
|
|
getSourceFile(fileName: string): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
interface TypeChecker {
|
|
|
|
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
|
|
|
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
|
|
|
getPropertiesOfType(type: Type): Symbol[];
|
|
|
|
getPropertyOfType(type: Type, propertyName: string): Symbol;
|
|
|
|
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
|
|
|
|
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
|
|
|
|
getReturnTypeOfSignature(signature: Signature): Type;
|
|
|
|
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
|
|
|
getSymbolAtLocation(node: Node): Symbol;
|
|
|
|
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
|
|
|
getTypeAtLocation(node: Node): Type;
|
|
|
|
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
|
|
|
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
|
|
|
|
getSymbolDisplayBuilder(): SymbolDisplayBuilder;
|
|
|
|
getFullyQualifiedName(symbol: Symbol): string;
|
|
|
|
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
|
|
|
getRootSymbols(symbol: Symbol): Symbol[];
|
|
|
|
getContextualType(node: Expression): Type;
|
|
|
|
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature;
|
|
|
|
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
|
|
|
|
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
|
|
|
isUndefinedSymbol(symbol: Symbol): boolean;
|
|
|
|
isArgumentsSymbol(symbol: Symbol): boolean;
|
2015-02-06 03:26:56 +01:00
|
|
|
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
2015-01-29 20:23:02 +01:00
|
|
|
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
|
|
|
getAliasedSymbol(symbol: Symbol): Symbol;
|
|
|
|
}
|
|
|
|
interface SymbolDisplayBuilder {
|
|
|
|
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
|
|
|
buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
|
|
|
|
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
|
|
|
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
|
|
|
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
|
|
|
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void;
|
|
|
|
buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
|
|
|
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
|
|
|
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
|
|
|
}
|
|
|
|
interface SymbolWriter {
|
|
|
|
writeKeyword(text: string): void;
|
|
|
|
writeOperator(text: string): void;
|
|
|
|
writePunctuation(text: string): void;
|
|
|
|
writeSpace(text: string): void;
|
|
|
|
writeStringLiteral(text: string): void;
|
|
|
|
writeParameter(text: string): void;
|
|
|
|
writeSymbol(text: string, symbol: Symbol): void;
|
|
|
|
writeLine(): void;
|
|
|
|
increaseIndent(): void;
|
|
|
|
decreaseIndent(): void;
|
|
|
|
clear(): void;
|
|
|
|
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
|
|
|
|
}
|
|
|
|
const enum TypeFormatFlags {
|
|
|
|
None = 0,
|
|
|
|
WriteArrayAsGenericType = 1,
|
|
|
|
UseTypeOfFunction = 2,
|
|
|
|
NoTruncation = 4,
|
|
|
|
WriteArrowStyleSignature = 8,
|
|
|
|
WriteOwnNameForAnyLike = 16,
|
|
|
|
WriteTypeArgumentsOfSignature = 32,
|
|
|
|
InElementType = 64,
|
2015-02-02 22:45:35 +01:00
|
|
|
UseFullyQualifiedType = 128,
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
const enum SymbolFormatFlags {
|
|
|
|
None = 0,
|
|
|
|
WriteTypeParametersOrArguments = 1,
|
|
|
|
UseOnlyExternalAliasing = 2,
|
|
|
|
}
|
|
|
|
const enum SymbolAccessibility {
|
|
|
|
Accessible = 0,
|
|
|
|
NotAccessible = 1,
|
|
|
|
CannotBeNamed = 2,
|
|
|
|
}
|
|
|
|
interface SymbolVisibilityResult {
|
|
|
|
accessibility: SymbolAccessibility;
|
2015-02-08 17:13:15 +01:00
|
|
|
aliasesToMakeVisible?: ImportEqualsDeclaration[];
|
2015-01-29 20:23:02 +01:00
|
|
|
errorSymbolName?: string;
|
|
|
|
errorNode?: Node;
|
|
|
|
}
|
|
|
|
interface SymbolAccessiblityResult extends SymbolVisibilityResult {
|
|
|
|
errorModuleName?: string;
|
|
|
|
}
|
|
|
|
interface EmitResolver {
|
2015-02-13 03:05:50 +01:00
|
|
|
getGeneratedNameForNode(node: ModuleDeclaration | EnumDeclaration | ImportDeclaration | ExportDeclaration): string;
|
2015-02-11 00:03:28 +01:00
|
|
|
getExpressionNameSubstitution(node: Identifier): string;
|
2015-01-29 20:23:02 +01:00
|
|
|
getExportAssignmentName(node: SourceFile): string;
|
2015-02-08 17:13:15 +01:00
|
|
|
isReferencedImportDeclaration(node: Node): boolean;
|
|
|
|
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
2015-01-29 20:23:02 +01:00
|
|
|
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
|
|
|
isDeclarationVisible(node: Declaration): boolean;
|
|
|
|
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
|
|
|
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
|
|
|
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
|
|
|
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
|
|
|
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
|
2015-02-06 03:26:56 +01:00
|
|
|
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
2015-01-29 20:23:02 +01:00
|
|
|
isUnknownIdentifier(location: Node, name: string): boolean;
|
|
|
|
}
|
|
|
|
const enum SymbolFlags {
|
|
|
|
FunctionScopedVariable = 1,
|
|
|
|
BlockScopedVariable = 2,
|
|
|
|
Property = 4,
|
|
|
|
EnumMember = 8,
|
|
|
|
Function = 16,
|
|
|
|
Class = 32,
|
|
|
|
Interface = 64,
|
|
|
|
ConstEnum = 128,
|
|
|
|
RegularEnum = 256,
|
|
|
|
ValueModule = 512,
|
|
|
|
NamespaceModule = 1024,
|
|
|
|
TypeLiteral = 2048,
|
|
|
|
ObjectLiteral = 4096,
|
|
|
|
Method = 8192,
|
|
|
|
Constructor = 16384,
|
|
|
|
GetAccessor = 32768,
|
|
|
|
SetAccessor = 65536,
|
|
|
|
Signature = 131072,
|
|
|
|
TypeParameter = 262144,
|
|
|
|
TypeAlias = 524288,
|
|
|
|
ExportValue = 1048576,
|
|
|
|
ExportType = 2097152,
|
|
|
|
ExportNamespace = 4194304,
|
|
|
|
Import = 8388608,
|
|
|
|
Instantiated = 16777216,
|
|
|
|
Merged = 33554432,
|
|
|
|
Transient = 67108864,
|
|
|
|
Prototype = 134217728,
|
|
|
|
UnionProperty = 268435456,
|
|
|
|
Optional = 536870912,
|
|
|
|
Enum = 384,
|
|
|
|
Variable = 3,
|
|
|
|
Value = 107455,
|
|
|
|
Type = 793056,
|
|
|
|
Namespace = 1536,
|
|
|
|
Module = 1536,
|
|
|
|
Accessor = 98304,
|
|
|
|
FunctionScopedVariableExcludes = 107454,
|
|
|
|
BlockScopedVariableExcludes = 107455,
|
|
|
|
ParameterExcludes = 107455,
|
|
|
|
PropertyExcludes = 107455,
|
|
|
|
EnumMemberExcludes = 107455,
|
|
|
|
FunctionExcludes = 106927,
|
|
|
|
ClassExcludes = 899583,
|
|
|
|
InterfaceExcludes = 792992,
|
|
|
|
RegularEnumExcludes = 899327,
|
|
|
|
ConstEnumExcludes = 899967,
|
|
|
|
ValueModuleExcludes = 106639,
|
|
|
|
NamespaceModuleExcludes = 0,
|
|
|
|
MethodExcludes = 99263,
|
|
|
|
GetAccessorExcludes = 41919,
|
|
|
|
SetAccessorExcludes = 74687,
|
|
|
|
TypeParameterExcludes = 530912,
|
|
|
|
TypeAliasExcludes = 793056,
|
|
|
|
ImportExcludes = 8388608,
|
|
|
|
ModuleMember = 8914931,
|
|
|
|
ExportHasLocal = 944,
|
|
|
|
HasLocals = 255504,
|
|
|
|
HasExports = 1952,
|
|
|
|
HasMembers = 6240,
|
|
|
|
IsContainer = 262128,
|
|
|
|
PropertyOrAccessor = 98308,
|
|
|
|
Export = 7340032,
|
|
|
|
}
|
|
|
|
interface Symbol {
|
|
|
|
flags: SymbolFlags;
|
|
|
|
name: string;
|
|
|
|
id?: number;
|
|
|
|
mergeId?: number;
|
|
|
|
declarations?: Declaration[];
|
|
|
|
parent?: Symbol;
|
|
|
|
members?: SymbolTable;
|
|
|
|
exports?: SymbolTable;
|
|
|
|
exportSymbol?: Symbol;
|
|
|
|
valueDeclaration?: Declaration;
|
|
|
|
constEnumOnlyModule?: boolean;
|
|
|
|
}
|
|
|
|
interface SymbolLinks {
|
|
|
|
target?: Symbol;
|
|
|
|
type?: Type;
|
|
|
|
declaredType?: Type;
|
|
|
|
mapper?: TypeMapper;
|
|
|
|
referenced?: boolean;
|
2015-02-11 19:52:29 +01:00
|
|
|
exportAssignmentChecked?: boolean;
|
|
|
|
exportAssignmentSymbol?: Symbol;
|
2015-01-29 20:23:02 +01:00
|
|
|
unionType?: UnionType;
|
2015-02-15 17:30:39 +01:00
|
|
|
resolvedExports?: SymbolTable;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
interface TransientSymbol extends Symbol, SymbolLinks {
|
|
|
|
}
|
|
|
|
interface SymbolTable {
|
|
|
|
[index: string]: Symbol;
|
|
|
|
}
|
|
|
|
const enum NodeCheckFlags {
|
|
|
|
TypeChecked = 1,
|
|
|
|
LexicalThis = 2,
|
|
|
|
CaptureThis = 4,
|
|
|
|
EmitExtends = 8,
|
|
|
|
SuperInstance = 16,
|
|
|
|
SuperStatic = 32,
|
|
|
|
ContextChecked = 64,
|
|
|
|
EnumValuesComputed = 128,
|
|
|
|
}
|
|
|
|
interface NodeLinks {
|
|
|
|
resolvedType?: Type;
|
|
|
|
resolvedSignature?: Signature;
|
|
|
|
resolvedSymbol?: Symbol;
|
|
|
|
flags?: NodeCheckFlags;
|
|
|
|
enumMemberValue?: number;
|
|
|
|
isIllegalTypeReferenceInConstraint?: boolean;
|
|
|
|
isVisible?: boolean;
|
2015-02-11 00:03:28 +01:00
|
|
|
generatedName?: string;
|
|
|
|
generatedNames?: Map<string>;
|
2015-01-29 20:23:02 +01:00
|
|
|
assignmentChecks?: Map<boolean>;
|
|
|
|
hasReportedStatementInAmbientContext?: boolean;
|
|
|
|
importOnRightSide?: Symbol;
|
|
|
|
}
|
|
|
|
const enum TypeFlags {
|
|
|
|
Any = 1,
|
|
|
|
String = 2,
|
|
|
|
Number = 4,
|
|
|
|
Boolean = 8,
|
|
|
|
Void = 16,
|
|
|
|
Undefined = 32,
|
|
|
|
Null = 64,
|
|
|
|
Enum = 128,
|
|
|
|
StringLiteral = 256,
|
|
|
|
TypeParameter = 512,
|
|
|
|
Class = 1024,
|
|
|
|
Interface = 2048,
|
|
|
|
Reference = 4096,
|
|
|
|
Tuple = 8192,
|
|
|
|
Union = 16384,
|
|
|
|
Anonymous = 32768,
|
|
|
|
FromSignature = 65536,
|
|
|
|
ObjectLiteral = 131072,
|
|
|
|
ContainsUndefinedOrNull = 262144,
|
|
|
|
ContainsObjectLiteral = 524288,
|
2015-02-04 02:18:50 +01:00
|
|
|
ESSymbol = 1048576,
|
|
|
|
Intrinsic = 1048703,
|
|
|
|
Primitive = 1049086,
|
2015-01-29 20:23:02 +01:00
|
|
|
StringLike = 258,
|
|
|
|
NumberLike = 132,
|
|
|
|
ObjectType = 48128,
|
|
|
|
RequiresWidening = 786432,
|
|
|
|
}
|
|
|
|
interface Type {
|
|
|
|
flags: TypeFlags;
|
|
|
|
id: number;
|
|
|
|
symbol?: Symbol;
|
|
|
|
}
|
|
|
|
interface IntrinsicType extends Type {
|
|
|
|
intrinsicName: string;
|
|
|
|
}
|
|
|
|
interface StringLiteralType extends Type {
|
|
|
|
text: string;
|
|
|
|
}
|
|
|
|
interface ObjectType extends Type {
|
|
|
|
}
|
|
|
|
interface InterfaceType extends ObjectType {
|
|
|
|
typeParameters: TypeParameter[];
|
|
|
|
baseTypes: ObjectType[];
|
|
|
|
declaredProperties: Symbol[];
|
|
|
|
declaredCallSignatures: Signature[];
|
|
|
|
declaredConstructSignatures: Signature[];
|
|
|
|
declaredStringIndexType: Type;
|
|
|
|
declaredNumberIndexType: Type;
|
|
|
|
}
|
|
|
|
interface TypeReference extends ObjectType {
|
|
|
|
target: GenericType;
|
|
|
|
typeArguments: Type[];
|
|
|
|
}
|
|
|
|
interface GenericType extends InterfaceType, TypeReference {
|
|
|
|
instantiations: Map<TypeReference>;
|
|
|
|
}
|
|
|
|
interface TupleType extends ObjectType {
|
|
|
|
elementTypes: Type[];
|
|
|
|
baseArrayType: TypeReference;
|
|
|
|
}
|
|
|
|
interface UnionType extends Type {
|
|
|
|
types: Type[];
|
|
|
|
resolvedProperties: SymbolTable;
|
|
|
|
}
|
|
|
|
interface ResolvedType extends ObjectType, UnionType {
|
|
|
|
members: SymbolTable;
|
|
|
|
properties: Symbol[];
|
|
|
|
callSignatures: Signature[];
|
|
|
|
constructSignatures: Signature[];
|
|
|
|
stringIndexType: Type;
|
|
|
|
numberIndexType: Type;
|
|
|
|
}
|
|
|
|
interface TypeParameter extends Type {
|
|
|
|
constraint: Type;
|
|
|
|
target?: TypeParameter;
|
|
|
|
mapper?: TypeMapper;
|
|
|
|
}
|
|
|
|
const enum SignatureKind {
|
|
|
|
Call = 0,
|
|
|
|
Construct = 1,
|
|
|
|
}
|
|
|
|
interface Signature {
|
|
|
|
declaration: SignatureDeclaration;
|
|
|
|
typeParameters: TypeParameter[];
|
|
|
|
parameters: Symbol[];
|
|
|
|
resolvedReturnType: Type;
|
|
|
|
minArgumentCount: number;
|
|
|
|
hasRestParameter: boolean;
|
|
|
|
hasStringLiterals: boolean;
|
|
|
|
target?: Signature;
|
|
|
|
mapper?: TypeMapper;
|
|
|
|
unionSignatures?: Signature[];
|
|
|
|
erasedSignatureCache?: Signature;
|
|
|
|
isolatedSignatureType?: ObjectType;
|
|
|
|
}
|
|
|
|
const enum IndexKind {
|
|
|
|
String = 0,
|
|
|
|
Number = 1,
|
|
|
|
}
|
|
|
|
interface TypeMapper {
|
|
|
|
(t: Type): Type;
|
|
|
|
}
|
|
|
|
interface TypeInferences {
|
|
|
|
primary: Type[];
|
|
|
|
secondary: Type[];
|
|
|
|
}
|
|
|
|
interface InferenceContext {
|
|
|
|
typeParameters: TypeParameter[];
|
|
|
|
inferUnionTypes: boolean;
|
|
|
|
inferences: TypeInferences[];
|
|
|
|
inferredTypes: Type[];
|
|
|
|
failedTypeParameterIndex?: number;
|
|
|
|
}
|
|
|
|
interface DiagnosticMessage {
|
|
|
|
key: string;
|
|
|
|
category: DiagnosticCategory;
|
|
|
|
code: number;
|
|
|
|
}
|
|
|
|
interface DiagnosticMessageChain {
|
|
|
|
messageText: string;
|
|
|
|
category: DiagnosticCategory;
|
|
|
|
code: number;
|
|
|
|
next?: DiagnosticMessageChain;
|
|
|
|
}
|
|
|
|
interface Diagnostic {
|
|
|
|
file: SourceFile;
|
|
|
|
start: number;
|
|
|
|
length: number;
|
2015-02-05 08:20:26 +01:00
|
|
|
messageText: string | DiagnosticMessageChain;
|
2015-01-29 20:23:02 +01:00
|
|
|
category: DiagnosticCategory;
|
|
|
|
code: number;
|
|
|
|
}
|
|
|
|
enum DiagnosticCategory {
|
|
|
|
Warning = 0,
|
|
|
|
Error = 1,
|
|
|
|
Message = 2,
|
|
|
|
}
|
|
|
|
interface CompilerOptions {
|
|
|
|
allowNonTsExtensions?: boolean;
|
|
|
|
charset?: string;
|
|
|
|
codepage?: number;
|
|
|
|
declaration?: boolean;
|
|
|
|
diagnostics?: boolean;
|
|
|
|
emitBOM?: boolean;
|
|
|
|
help?: boolean;
|
|
|
|
listFiles?: boolean;
|
|
|
|
locale?: string;
|
|
|
|
mapRoot?: string;
|
|
|
|
module?: ModuleKind;
|
|
|
|
noEmit?: boolean;
|
|
|
|
noEmitOnError?: boolean;
|
|
|
|
noErrorTruncation?: boolean;
|
|
|
|
noImplicitAny?: boolean;
|
|
|
|
noLib?: boolean;
|
|
|
|
noLibCheck?: boolean;
|
|
|
|
noResolve?: boolean;
|
|
|
|
out?: string;
|
|
|
|
outDir?: string;
|
|
|
|
preserveConstEnums?: boolean;
|
|
|
|
project?: string;
|
|
|
|
removeComments?: boolean;
|
|
|
|
sourceMap?: boolean;
|
|
|
|
sourceRoot?: string;
|
|
|
|
suppressImplicitAnyIndexErrors?: boolean;
|
|
|
|
target?: ScriptTarget;
|
|
|
|
version?: boolean;
|
|
|
|
watch?: boolean;
|
2015-02-03 22:47:46 +01:00
|
|
|
stripInternal?: boolean;
|
2015-01-29 20:23:02 +01:00
|
|
|
[option: string]: string | number | boolean;
|
|
|
|
}
|
|
|
|
const enum ModuleKind {
|
|
|
|
None = 0,
|
|
|
|
CommonJS = 1,
|
|
|
|
AMD = 2,
|
|
|
|
}
|
|
|
|
interface LineAndCharacter {
|
|
|
|
line: number;
|
|
|
|
character: number;
|
|
|
|
}
|
|
|
|
const enum ScriptTarget {
|
|
|
|
ES3 = 0,
|
|
|
|
ES5 = 1,
|
|
|
|
ES6 = 2,
|
|
|
|
Latest = 2,
|
|
|
|
}
|
|
|
|
interface ParsedCommandLine {
|
|
|
|
options: CompilerOptions;
|
2015-02-04 01:08:46 +01:00
|
|
|
fileNames: string[];
|
2015-01-29 20:23:02 +01:00
|
|
|
errors: Diagnostic[];
|
|
|
|
}
|
|
|
|
interface CommandLineOption {
|
|
|
|
name: string;
|
|
|
|
type: string | Map<number>;
|
|
|
|
isFilePath?: boolean;
|
|
|
|
shortName?: string;
|
|
|
|
description?: DiagnosticMessage;
|
|
|
|
paramType?: DiagnosticMessage;
|
|
|
|
error?: DiagnosticMessage;
|
2015-02-03 22:47:46 +01:00
|
|
|
experimental?: boolean;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
const enum CharacterCodes {
|
|
|
|
nullCharacter = 0,
|
|
|
|
maxAsciiCharacter = 127,
|
|
|
|
lineFeed = 10,
|
|
|
|
carriageReturn = 13,
|
|
|
|
lineSeparator = 8232,
|
|
|
|
paragraphSeparator = 8233,
|
|
|
|
nextLine = 133,
|
|
|
|
space = 32,
|
|
|
|
nonBreakingSpace = 160,
|
|
|
|
enQuad = 8192,
|
|
|
|
emQuad = 8193,
|
|
|
|
enSpace = 8194,
|
|
|
|
emSpace = 8195,
|
|
|
|
threePerEmSpace = 8196,
|
|
|
|
fourPerEmSpace = 8197,
|
|
|
|
sixPerEmSpace = 8198,
|
|
|
|
figureSpace = 8199,
|
|
|
|
punctuationSpace = 8200,
|
|
|
|
thinSpace = 8201,
|
|
|
|
hairSpace = 8202,
|
|
|
|
zeroWidthSpace = 8203,
|
|
|
|
narrowNoBreakSpace = 8239,
|
|
|
|
ideographicSpace = 12288,
|
|
|
|
mathematicalSpace = 8287,
|
|
|
|
ogham = 5760,
|
|
|
|
_ = 95,
|
|
|
|
$ = 36,
|
|
|
|
_0 = 48,
|
|
|
|
_1 = 49,
|
|
|
|
_2 = 50,
|
|
|
|
_3 = 51,
|
|
|
|
_4 = 52,
|
|
|
|
_5 = 53,
|
|
|
|
_6 = 54,
|
|
|
|
_7 = 55,
|
|
|
|
_8 = 56,
|
|
|
|
_9 = 57,
|
|
|
|
a = 97,
|
|
|
|
b = 98,
|
|
|
|
c = 99,
|
|
|
|
d = 100,
|
|
|
|
e = 101,
|
|
|
|
f = 102,
|
|
|
|
g = 103,
|
|
|
|
h = 104,
|
|
|
|
i = 105,
|
|
|
|
j = 106,
|
|
|
|
k = 107,
|
|
|
|
l = 108,
|
|
|
|
m = 109,
|
|
|
|
n = 110,
|
|
|
|
o = 111,
|
|
|
|
p = 112,
|
|
|
|
q = 113,
|
|
|
|
r = 114,
|
|
|
|
s = 115,
|
|
|
|
t = 116,
|
|
|
|
u = 117,
|
|
|
|
v = 118,
|
|
|
|
w = 119,
|
|
|
|
x = 120,
|
|
|
|
y = 121,
|
|
|
|
z = 122,
|
|
|
|
A = 65,
|
|
|
|
B = 66,
|
|
|
|
C = 67,
|
|
|
|
D = 68,
|
|
|
|
E = 69,
|
|
|
|
F = 70,
|
|
|
|
G = 71,
|
|
|
|
H = 72,
|
|
|
|
I = 73,
|
|
|
|
J = 74,
|
|
|
|
K = 75,
|
|
|
|
L = 76,
|
|
|
|
M = 77,
|
|
|
|
N = 78,
|
|
|
|
O = 79,
|
|
|
|
P = 80,
|
|
|
|
Q = 81,
|
|
|
|
R = 82,
|
|
|
|
S = 83,
|
|
|
|
T = 84,
|
|
|
|
U = 85,
|
|
|
|
V = 86,
|
|
|
|
W = 87,
|
|
|
|
X = 88,
|
|
|
|
Y = 89,
|
|
|
|
Z = 90,
|
|
|
|
ampersand = 38,
|
|
|
|
asterisk = 42,
|
|
|
|
at = 64,
|
|
|
|
backslash = 92,
|
|
|
|
backtick = 96,
|
|
|
|
bar = 124,
|
|
|
|
caret = 94,
|
|
|
|
closeBrace = 125,
|
|
|
|
closeBracket = 93,
|
|
|
|
closeParen = 41,
|
|
|
|
colon = 58,
|
|
|
|
comma = 44,
|
|
|
|
dot = 46,
|
|
|
|
doubleQuote = 34,
|
|
|
|
equals = 61,
|
|
|
|
exclamation = 33,
|
|
|
|
greaterThan = 62,
|
2015-02-20 09:22:41 +01:00
|
|
|
hash = 35,
|
2015-01-29 20:23:02 +01:00
|
|
|
lessThan = 60,
|
|
|
|
minus = 45,
|
|
|
|
openBrace = 123,
|
|
|
|
openBracket = 91,
|
|
|
|
openParen = 40,
|
|
|
|
percent = 37,
|
|
|
|
plus = 43,
|
|
|
|
question = 63,
|
|
|
|
semicolon = 59,
|
|
|
|
singleQuote = 39,
|
|
|
|
slash = 47,
|
|
|
|
tilde = 126,
|
|
|
|
backspace = 8,
|
|
|
|
formFeed = 12,
|
|
|
|
byteOrderMark = 65279,
|
|
|
|
tab = 9,
|
|
|
|
verticalTab = 11,
|
|
|
|
}
|
|
|
|
interface CancellationToken {
|
|
|
|
isCancellationRequested(): boolean;
|
|
|
|
}
|
|
|
|
interface CompilerHost {
|
2015-02-04 01:08:46 +01:00
|
|
|
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
|
|
|
getDefaultLibFileName(options: CompilerOptions): string;
|
2015-01-29 20:23:02 +01:00
|
|
|
getCancellationToken?(): CancellationToken;
|
2015-02-05 01:53:14 +01:00
|
|
|
writeFile: WriteFileCallback;
|
2015-01-29 20:23:02 +01:00
|
|
|
getCurrentDirectory(): string;
|
|
|
|
getCanonicalFileName(fileName: string): string;
|
|
|
|
useCaseSensitiveFileNames(): boolean;
|
|
|
|
getNewLine(): string;
|
|
|
|
}
|
|
|
|
interface TextSpan {
|
|
|
|
start: number;
|
|
|
|
length: number;
|
|
|
|
}
|
|
|
|
interface TextChangeRange {
|
|
|
|
span: TextSpan;
|
|
|
|
newLength: number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module "typescript" {
|
|
|
|
interface ErrorCallback {
|
|
|
|
(message: DiagnosticMessage, length: number): void;
|
|
|
|
}
|
|
|
|
interface Scanner {
|
|
|
|
getStartPos(): number;
|
|
|
|
getToken(): SyntaxKind;
|
|
|
|
getTextPos(): number;
|
|
|
|
getTokenPos(): number;
|
|
|
|
getTokenText(): string;
|
|
|
|
getTokenValue(): string;
|
|
|
|
hasPrecedingLineBreak(): boolean;
|
|
|
|
isIdentifier(): boolean;
|
|
|
|
isReservedWord(): boolean;
|
|
|
|
isUnterminated(): boolean;
|
|
|
|
reScanGreaterToken(): SyntaxKind;
|
|
|
|
reScanSlashToken(): SyntaxKind;
|
|
|
|
reScanTemplateToken(): SyntaxKind;
|
|
|
|
scan(): SyntaxKind;
|
|
|
|
setText(text: string): void;
|
|
|
|
setTextPos(textPos: number): void;
|
|
|
|
lookAhead<T>(callback: () => T): T;
|
|
|
|
tryScan<T>(callback: () => T): T;
|
|
|
|
}
|
|
|
|
function tokenToString(t: SyntaxKind): string;
|
|
|
|
function computeLineStarts(text: string): number[];
|
2015-02-17 04:55:32 +01:00
|
|
|
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
|
|
|
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
2015-02-03 20:33:56 +01:00
|
|
|
function getLineStarts(sourceFile: SourceFile): number[];
|
|
|
|
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
2015-01-29 20:23:02 +01:00
|
|
|
line: number;
|
|
|
|
character: number;
|
|
|
|
};
|
2015-02-03 20:33:56 +01:00
|
|
|
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
2015-01-29 20:23:02 +01:00
|
|
|
function isWhiteSpace(ch: number): boolean;
|
|
|
|
function isLineBreak(ch: number): boolean;
|
|
|
|
function isOctalDigit(ch: number): boolean;
|
|
|
|
function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number;
|
|
|
|
function getLeadingCommentRanges(text: string, pos: number): CommentRange[];
|
|
|
|
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
|
|
|
|
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
|
|
|
|
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
|
|
|
|
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner;
|
|
|
|
}
|
|
|
|
declare module "typescript" {
|
|
|
|
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
|
|
|
function createNode(kind: SyntaxKind): Node;
|
|
|
|
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
|
|
|
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
2015-02-09 01:10:16 +01:00
|
|
|
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
2015-02-04 01:08:46 +01:00
|
|
|
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
function isLeftHandSideExpression(expr: Expression): boolean;
|
|
|
|
function isAssignmentOperator(token: SyntaxKind): boolean;
|
|
|
|
}
|
|
|
|
declare module "typescript" {
|
|
|
|
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
|
|
|
|
}
|
|
|
|
declare module "typescript" {
|
|
|
|
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
2015-02-05 10:47:29 +01:00
|
|
|
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
|
|
|
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
2015-02-05 02:02:26 +01:00
|
|
|
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
declare module "typescript" {
|
|
|
|
var servicesVersion: string;
|
|
|
|
interface Node {
|
|
|
|
getSourceFile(): SourceFile;
|
|
|
|
getChildCount(sourceFile?: SourceFile): number;
|
|
|
|
getChildAt(index: number, sourceFile?: SourceFile): Node;
|
|
|
|
getChildren(sourceFile?: SourceFile): Node[];
|
|
|
|
getStart(sourceFile?: SourceFile): number;
|
|
|
|
getFullStart(): number;
|
|
|
|
getEnd(): number;
|
|
|
|
getWidth(sourceFile?: SourceFile): number;
|
|
|
|
getFullWidth(): number;
|
|
|
|
getLeadingTriviaWidth(sourceFile?: SourceFile): number;
|
|
|
|
getFullText(sourceFile?: SourceFile): string;
|
|
|
|
getText(sourceFile?: SourceFile): string;
|
|
|
|
getFirstToken(sourceFile?: SourceFile): Node;
|
|
|
|
getLastToken(sourceFile?: SourceFile): Node;
|
|
|
|
}
|
|
|
|
interface Symbol {
|
|
|
|
getFlags(): SymbolFlags;
|
|
|
|
getName(): string;
|
|
|
|
getDeclarations(): Declaration[];
|
|
|
|
getDocumentationComment(): SymbolDisplayPart[];
|
|
|
|
}
|
|
|
|
interface Type {
|
|
|
|
getFlags(): TypeFlags;
|
|
|
|
getSymbol(): Symbol;
|
|
|
|
getProperties(): Symbol[];
|
|
|
|
getProperty(propertyName: string): Symbol;
|
|
|
|
getApparentProperties(): Symbol[];
|
|
|
|
getCallSignatures(): Signature[];
|
|
|
|
getConstructSignatures(): Signature[];
|
|
|
|
getStringIndexType(): Type;
|
|
|
|
getNumberIndexType(): Type;
|
|
|
|
}
|
|
|
|
interface Signature {
|
|
|
|
getDeclaration(): SignatureDeclaration;
|
|
|
|
getTypeParameters(): Type[];
|
|
|
|
getParameters(): Symbol[];
|
|
|
|
getReturnType(): Type;
|
|
|
|
getDocumentationComment(): SymbolDisplayPart[];
|
|
|
|
}
|
|
|
|
interface SourceFile {
|
|
|
|
version: string;
|
|
|
|
scriptSnapshot: IScriptSnapshot;
|
|
|
|
nameTable: Map<string>;
|
|
|
|
getNamedDeclarations(): Declaration[];
|
2015-02-17 04:55:32 +01:00
|
|
|
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
2015-02-03 20:33:56 +01:00
|
|
|
getLineStarts(): number[];
|
2015-02-17 04:55:32 +01:00
|
|
|
getPositionOfLineAndCharacter(line: number, character: number): number;
|
2015-02-03 20:33:56 +01:00
|
|
|
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
|
|
|
* snapshot is observably immutable. i.e. the same calls with the same parameters will return
|
|
|
|
* the same values.
|
|
|
|
*/
|
|
|
|
interface IScriptSnapshot {
|
|
|
|
/** Gets a portion of the script snapshot specified by [start, end). */
|
|
|
|
getText(start: number, end: number): string;
|
|
|
|
/** Gets the length of this script snapshot. */
|
|
|
|
getLength(): number;
|
|
|
|
/**
|
|
|
|
* Gets the TextChangeRange that describe how the text changed between this text and
|
|
|
|
* an older version. This information is used by the incremental parser to determine
|
|
|
|
* what sections of the script need to be re-parsed. 'undefined' can be returned if the
|
|
|
|
* change range cannot be determined. However, in that case, incremental parsing will
|
|
|
|
* not happen and the entire document will be re - parsed.
|
|
|
|
*/
|
|
|
|
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
|
|
|
|
}
|
|
|
|
module ScriptSnapshot {
|
|
|
|
function fromString(text: string): IScriptSnapshot;
|
|
|
|
}
|
|
|
|
interface PreProcessedFileInfo {
|
|
|
|
referencedFiles: FileReference[];
|
|
|
|
importedFiles: FileReference[];
|
|
|
|
isLibFile: boolean;
|
|
|
|
}
|
|
|
|
interface LanguageServiceHost {
|
|
|
|
getCompilationSettings(): CompilerOptions;
|
|
|
|
getNewLine?(): string;
|
|
|
|
getScriptFileNames(): string[];
|
|
|
|
getScriptVersion(fileName: string): string;
|
|
|
|
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
|
|
|
getLocalizedDiagnosticMessages?(): any;
|
|
|
|
getCancellationToken?(): CancellationToken;
|
|
|
|
getCurrentDirectory(): string;
|
2015-02-04 01:08:46 +01:00
|
|
|
getDefaultLibFileName(options: CompilerOptions): string;
|
2015-01-29 20:23:02 +01:00
|
|
|
log?(s: string): void;
|
|
|
|
trace?(s: string): void;
|
|
|
|
error?(s: string): void;
|
|
|
|
}
|
|
|
|
interface LanguageService {
|
|
|
|
cleanupSemanticCache(): void;
|
|
|
|
getSyntacticDiagnostics(fileName: string): Diagnostic[];
|
|
|
|
getSemanticDiagnostics(fileName: string): Diagnostic[];
|
|
|
|
getCompilerOptionsDiagnostics(): Diagnostic[];
|
|
|
|
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
|
|
|
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
|
|
|
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
|
|
|
|
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
|
|
|
|
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
|
|
|
|
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan;
|
|
|
|
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan;
|
|
|
|
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems;
|
|
|
|
getRenameInfo(fileName: string, position: number): RenameInfo;
|
|
|
|
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
|
|
|
|
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
|
|
|
|
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
|
|
|
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
2015-02-20 00:13:03 +01:00
|
|
|
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
|
2015-01-29 20:23:02 +01:00
|
|
|
getNavigationBarItems(fileName: string): NavigationBarItem[];
|
|
|
|
getOutliningSpans(fileName: string): OutliningSpan[];
|
|
|
|
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
|
|
|
|
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
|
|
|
|
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number;
|
|
|
|
getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[];
|
|
|
|
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
|
|
|
|
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
|
|
|
getEmitOutput(fileName: string): EmitOutput;
|
|
|
|
getProgram(): Program;
|
2015-02-04 01:08:46 +01:00
|
|
|
getSourceFile(fileName: string): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
dispose(): void;
|
|
|
|
}
|
|
|
|
interface ClassifiedSpan {
|
|
|
|
textSpan: TextSpan;
|
|
|
|
classificationType: string;
|
|
|
|
}
|
|
|
|
interface NavigationBarItem {
|
|
|
|
text: string;
|
|
|
|
kind: string;
|
|
|
|
kindModifiers: string;
|
|
|
|
spans: TextSpan[];
|
|
|
|
childItems: NavigationBarItem[];
|
|
|
|
indent: number;
|
|
|
|
bolded: boolean;
|
|
|
|
grayed: boolean;
|
|
|
|
}
|
|
|
|
interface TodoCommentDescriptor {
|
|
|
|
text: string;
|
|
|
|
priority: number;
|
|
|
|
}
|
|
|
|
interface TodoComment {
|
|
|
|
descriptor: TodoCommentDescriptor;
|
|
|
|
message: string;
|
|
|
|
position: number;
|
|
|
|
}
|
|
|
|
class TextChange {
|
|
|
|
span: TextSpan;
|
|
|
|
newText: string;
|
|
|
|
}
|
|
|
|
interface RenameLocation {
|
|
|
|
textSpan: TextSpan;
|
|
|
|
fileName: string;
|
|
|
|
}
|
|
|
|
interface ReferenceEntry {
|
|
|
|
textSpan: TextSpan;
|
|
|
|
fileName: string;
|
|
|
|
isWriteAccess: boolean;
|
|
|
|
}
|
|
|
|
interface NavigateToItem {
|
|
|
|
name: string;
|
|
|
|
kind: string;
|
|
|
|
kindModifiers: string;
|
|
|
|
matchKind: string;
|
2015-02-23 06:25:43 +01:00
|
|
|
isCaseSensitive: boolean;
|
2015-01-29 20:23:02 +01:00
|
|
|
fileName: string;
|
|
|
|
textSpan: TextSpan;
|
|
|
|
containerName: string;
|
|
|
|
containerKind: string;
|
|
|
|
}
|
|
|
|
interface EditorOptions {
|
|
|
|
IndentSize: number;
|
|
|
|
TabSize: number;
|
|
|
|
NewLineCharacter: string;
|
|
|
|
ConvertTabsToSpaces: boolean;
|
|
|
|
}
|
|
|
|
interface FormatCodeOptions extends EditorOptions {
|
|
|
|
InsertSpaceAfterCommaDelimiter: boolean;
|
|
|
|
InsertSpaceAfterSemicolonInForStatements: boolean;
|
|
|
|
InsertSpaceBeforeAndAfterBinaryOperators: boolean;
|
|
|
|
InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
|
|
|
|
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
|
|
|
|
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
|
|
|
|
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
|
|
|
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
2015-02-16 21:04:34 +01:00
|
|
|
[s: string]: boolean | number | string;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
interface DefinitionInfo {
|
|
|
|
fileName: string;
|
|
|
|
textSpan: TextSpan;
|
|
|
|
kind: string;
|
|
|
|
name: string;
|
|
|
|
containerKind: string;
|
|
|
|
containerName: string;
|
|
|
|
}
|
|
|
|
enum SymbolDisplayPartKind {
|
|
|
|
aliasName = 0,
|
|
|
|
className = 1,
|
|
|
|
enumName = 2,
|
|
|
|
fieldName = 3,
|
|
|
|
interfaceName = 4,
|
|
|
|
keyword = 5,
|
|
|
|
lineBreak = 6,
|
|
|
|
numericLiteral = 7,
|
|
|
|
stringLiteral = 8,
|
|
|
|
localName = 9,
|
|
|
|
methodName = 10,
|
|
|
|
moduleName = 11,
|
|
|
|
operator = 12,
|
|
|
|
parameterName = 13,
|
|
|
|
propertyName = 14,
|
|
|
|
punctuation = 15,
|
|
|
|
space = 16,
|
|
|
|
text = 17,
|
|
|
|
typeParameterName = 18,
|
|
|
|
enumMemberName = 19,
|
|
|
|
functionName = 20,
|
|
|
|
regularExpressionLiteral = 21,
|
|
|
|
}
|
|
|
|
interface SymbolDisplayPart {
|
|
|
|
text: string;
|
|
|
|
kind: string;
|
|
|
|
}
|
|
|
|
interface QuickInfo {
|
|
|
|
kind: string;
|
|
|
|
kindModifiers: string;
|
|
|
|
textSpan: TextSpan;
|
|
|
|
displayParts: SymbolDisplayPart[];
|
|
|
|
documentation: SymbolDisplayPart[];
|
|
|
|
}
|
|
|
|
interface RenameInfo {
|
|
|
|
canRename: boolean;
|
|
|
|
localizedErrorMessage: string;
|
|
|
|
displayName: string;
|
|
|
|
fullDisplayName: string;
|
|
|
|
kind: string;
|
|
|
|
kindModifiers: string;
|
|
|
|
triggerSpan: TextSpan;
|
|
|
|
}
|
|
|
|
interface SignatureHelpParameter {
|
|
|
|
name: string;
|
|
|
|
documentation: SymbolDisplayPart[];
|
|
|
|
displayParts: SymbolDisplayPart[];
|
|
|
|
isOptional: boolean;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Represents a single signature to show in signature help.
|
|
|
|
* The id is used for subsequent calls into the language service to ask questions about the
|
|
|
|
* signature help item in the context of any documents that have been updated. i.e. after
|
|
|
|
* an edit has happened, while signature help is still active, the host can ask important
|
|
|
|
* questions like 'what parameter is the user currently contained within?'.
|
|
|
|
*/
|
|
|
|
interface SignatureHelpItem {
|
|
|
|
isVariadic: boolean;
|
|
|
|
prefixDisplayParts: SymbolDisplayPart[];
|
|
|
|
suffixDisplayParts: SymbolDisplayPart[];
|
|
|
|
separatorDisplayParts: SymbolDisplayPart[];
|
|
|
|
parameters: SignatureHelpParameter[];
|
|
|
|
documentation: SymbolDisplayPart[];
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Represents a set of signature help items, and the preferred item that should be selected.
|
|
|
|
*/
|
|
|
|
interface SignatureHelpItems {
|
|
|
|
items: SignatureHelpItem[];
|
|
|
|
applicableSpan: TextSpan;
|
|
|
|
selectedItemIndex: number;
|
|
|
|
argumentIndex: number;
|
|
|
|
argumentCount: number;
|
|
|
|
}
|
|
|
|
interface CompletionInfo {
|
|
|
|
isMemberCompletion: boolean;
|
2015-02-04 01:31:53 +01:00
|
|
|
isNewIdentifierLocation: boolean;
|
2015-01-29 20:23:02 +01:00
|
|
|
entries: CompletionEntry[];
|
|
|
|
}
|
|
|
|
interface CompletionEntry {
|
|
|
|
name: string;
|
|
|
|
kind: string;
|
|
|
|
kindModifiers: string;
|
|
|
|
}
|
|
|
|
interface CompletionEntryDetails {
|
|
|
|
name: string;
|
|
|
|
kind: string;
|
|
|
|
kindModifiers: string;
|
|
|
|
displayParts: SymbolDisplayPart[];
|
|
|
|
documentation: SymbolDisplayPart[];
|
|
|
|
}
|
|
|
|
interface OutliningSpan {
|
|
|
|
/** The span of the document to actually collapse. */
|
|
|
|
textSpan: TextSpan;
|
|
|
|
/** The span of the document to display when the user hovers over the collapsed span. */
|
|
|
|
hintSpan: TextSpan;
|
|
|
|
/** The text to display in the editor for the collapsed region. */
|
|
|
|
bannerText: string;
|
|
|
|
/**
|
|
|
|
* Whether or not this region should be automatically collapsed when
|
|
|
|
* the 'Collapse to Definitions' command is invoked.
|
|
|
|
*/
|
|
|
|
autoCollapse: boolean;
|
|
|
|
}
|
|
|
|
interface EmitOutput {
|
|
|
|
outputFiles: OutputFile[];
|
2015-02-06 00:50:18 +01:00
|
|
|
emitSkipped: boolean;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
const enum OutputFileType {
|
|
|
|
JavaScript = 0,
|
|
|
|
SourceMap = 1,
|
|
|
|
Declaration = 2,
|
|
|
|
}
|
|
|
|
interface OutputFile {
|
|
|
|
name: string;
|
|
|
|
writeByteOrderMark: boolean;
|
|
|
|
text: string;
|
|
|
|
}
|
|
|
|
const enum EndOfLineState {
|
|
|
|
Start = 0,
|
|
|
|
InMultiLineCommentTrivia = 1,
|
|
|
|
InSingleQuoteStringLiteral = 2,
|
|
|
|
InDoubleQuoteStringLiteral = 3,
|
2015-02-13 01:46:25 +01:00
|
|
|
InTemplateHeadOrNoSubstitutionTemplate = 4,
|
|
|
|
InTemplateMiddleOrTail = 5,
|
|
|
|
InTemplateSubstitutionPosition = 6,
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
enum TokenClass {
|
|
|
|
Punctuation = 0,
|
|
|
|
Keyword = 1,
|
|
|
|
Operator = 2,
|
|
|
|
Comment = 3,
|
|
|
|
Whitespace = 4,
|
|
|
|
Identifier = 5,
|
|
|
|
NumberLiteral = 6,
|
|
|
|
StringLiteral = 7,
|
|
|
|
RegExpLiteral = 8,
|
|
|
|
}
|
|
|
|
interface ClassificationResult {
|
|
|
|
finalLexState: EndOfLineState;
|
|
|
|
entries: ClassificationInfo[];
|
|
|
|
}
|
|
|
|
interface ClassificationInfo {
|
|
|
|
length: number;
|
|
|
|
classification: TokenClass;
|
|
|
|
}
|
|
|
|
interface Classifier {
|
2015-02-13 22:33:12 +01:00
|
|
|
/**
|
|
|
|
* Gives lexical classifications of tokens on a line without any syntactic context.
|
|
|
|
* For instance, a token consisting of the text 'string' can be either an identifier
|
|
|
|
* named 'string' or the keyword 'string', however, because this classifier is not aware,
|
|
|
|
* it relies on certain heuristics to give acceptable results. For classifications where
|
|
|
|
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
|
|
|
|
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
|
|
|
|
* lexical, syntactic, and semantic classifiers may issue the best user experience.
|
|
|
|
*
|
|
|
|
* @param text The text of a line to classify.
|
|
|
|
* @param lexState The state of the lexical classifier at the end of the previous line.
|
|
|
|
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
|
|
|
|
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
|
|
|
|
* certain heuristics may be used in its place; however, if there is a
|
|
|
|
* syntactic classifier (syntacticClassifierAbsent=false), certain
|
|
|
|
* classifications which may be incorrectly categorized will be given
|
|
|
|
* back as Identifiers in order to allow the syntactic classifier to
|
|
|
|
* subsume the classification.
|
|
|
|
*/
|
|
|
|
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* The document registry represents a store of SourceFile objects that can be shared between
|
|
|
|
* multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
|
|
|
|
* of files in the context.
|
|
|
|
* SourceFile objects account for most of the memory usage by the language service. Sharing
|
|
|
|
* the same DocumentRegistry instance between different instances of LanguageService allow
|
|
|
|
* for more efficient memory utilization since all projects will share at least the library
|
|
|
|
* file (lib.d.ts).
|
|
|
|
*
|
|
|
|
* A more advanced use of the document registry is to serialize sourceFile objects to disk
|
|
|
|
* and re-hydrate them when needed.
|
|
|
|
*
|
|
|
|
* To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
|
|
|
|
* to all subsequent createLanguageService calls.
|
|
|
|
*/
|
|
|
|
interface DocumentRegistry {
|
|
|
|
/**
|
2015-02-04 01:08:46 +01:00
|
|
|
* Request a stored SourceFile with a given fileName and compilationSettings.
|
2015-01-29 20:23:02 +01:00
|
|
|
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
|
|
|
* the SourceFile if was not found in the registry.
|
|
|
|
*
|
2015-02-04 01:08:46 +01:00
|
|
|
* @param fileName The name of the file requested
|
2015-01-29 20:23:02 +01:00
|
|
|
* @param compilationSettings Some compilation settings like target affects the
|
|
|
|
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
|
|
|
* multiple copies of the same file for different compilation settings.
|
|
|
|
* @parm scriptSnapshot Text of the file. Only used if the file was not found
|
|
|
|
* in the registry and a new one was created.
|
|
|
|
* @parm version Current version of the file. Only used if the file was not found
|
|
|
|
* in the registry and a new one was created.
|
|
|
|
*/
|
2015-02-04 01:08:46 +01:00
|
|
|
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
/**
|
2015-02-04 01:08:46 +01:00
|
|
|
* Request an updated version of an already existing SourceFile with a given fileName
|
2015-01-29 20:23:02 +01:00
|
|
|
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
|
|
|
* to get an updated SourceFile.
|
|
|
|
*
|
|
|
|
* Note: It is not allowed to call update on a SourceFile that was not acquired from this
|
|
|
|
* registry originally.
|
|
|
|
*
|
|
|
|
* @param sourceFile The original sourceFile object to update
|
2015-02-04 01:08:46 +01:00
|
|
|
* @param fileName The name of the file requested
|
2015-01-29 20:23:02 +01:00
|
|
|
* @param compilationSettings Some compilation settings like target affects the
|
|
|
|
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
|
|
|
* multiple copies of the same file for different compilation settings.
|
|
|
|
* @parm scriptSnapshot Text of the file. Only used if the file was not found
|
|
|
|
* in the registry and a new one was created.
|
|
|
|
* @parm version Current version of the file. Only used if the file was not found
|
|
|
|
* in the registry and a new one was created.
|
|
|
|
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
|
|
|
* was not found in the registry and a new one was created.
|
|
|
|
*/
|
2015-02-04 01:08:46 +01:00
|
|
|
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
/**
|
|
|
|
* Informs the DocumentRegistry that a file is not needed any longer.
|
|
|
|
*
|
|
|
|
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
|
|
|
* this registry originally.
|
|
|
|
*
|
2015-02-04 01:08:46 +01:00
|
|
|
* @param fileName The name of the file to be released
|
2015-01-29 20:23:02 +01:00
|
|
|
* @param compilationSettings The compilation settings used to acquire the file
|
|
|
|
*/
|
2015-02-04 01:08:46 +01:00
|
|
|
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
2015-01-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
class ScriptElementKind {
|
|
|
|
static unknown: string;
|
|
|
|
static keyword: string;
|
|
|
|
static scriptElement: string;
|
|
|
|
static moduleElement: string;
|
|
|
|
static classElement: string;
|
|
|
|
static interfaceElement: string;
|
|
|
|
static typeElement: string;
|
|
|
|
static enumElement: string;
|
|
|
|
static variableElement: string;
|
|
|
|
static localVariableElement: string;
|
|
|
|
static functionElement: string;
|
|
|
|
static localFunctionElement: string;
|
|
|
|
static memberFunctionElement: string;
|
|
|
|
static memberGetAccessorElement: string;
|
|
|
|
static memberSetAccessorElement: string;
|
|
|
|
static memberVariableElement: string;
|
|
|
|
static constructorImplementationElement: string;
|
|
|
|
static callSignatureElement: string;
|
|
|
|
static indexSignatureElement: string;
|
|
|
|
static constructSignatureElement: string;
|
|
|
|
static parameterElement: string;
|
|
|
|
static typeParameterElement: string;
|
|
|
|
static primitiveType: string;
|
|
|
|
static label: string;
|
|
|
|
static alias: string;
|
|
|
|
static constElement: string;
|
|
|
|
static letElement: string;
|
|
|
|
}
|
|
|
|
class ScriptElementKindModifier {
|
|
|
|
static none: string;
|
|
|
|
static publicMemberModifier: string;
|
|
|
|
static privateMemberModifier: string;
|
|
|
|
static protectedMemberModifier: string;
|
|
|
|
static exportedModifier: string;
|
|
|
|
static ambientModifier: string;
|
|
|
|
static staticModifier: string;
|
|
|
|
}
|
|
|
|
class ClassificationTypeNames {
|
|
|
|
static comment: string;
|
|
|
|
static identifier: string;
|
|
|
|
static keyword: string;
|
|
|
|
static numericLiteral: string;
|
|
|
|
static operator: string;
|
|
|
|
static stringLiteral: string;
|
|
|
|
static whiteSpace: string;
|
|
|
|
static text: string;
|
|
|
|
static punctuation: string;
|
|
|
|
static className: string;
|
|
|
|
static enumName: string;
|
|
|
|
static interfaceName: string;
|
|
|
|
static moduleName: string;
|
|
|
|
static typeParameterName: string;
|
|
|
|
static typeAlias: string;
|
|
|
|
}
|
|
|
|
interface DisplayPartsSymbolWriter extends SymbolWriter {
|
|
|
|
displayParts(): SymbolDisplayPart[];
|
|
|
|
}
|
|
|
|
function displayPartsToString(displayParts: SymbolDisplayPart[]): string;
|
|
|
|
function getDefaultCompilerOptions(): CompilerOptions;
|
|
|
|
class OperationCanceledException {
|
|
|
|
}
|
|
|
|
class CancellationTokenObject {
|
|
|
|
private cancellationToken;
|
|
|
|
static None: CancellationTokenObject;
|
|
|
|
constructor(cancellationToken: CancellationToken);
|
|
|
|
isCancellationRequested(): boolean;
|
|
|
|
throwIfCancellationRequested(): void;
|
|
|
|
}
|
2015-02-04 01:08:46 +01:00
|
|
|
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
var disableIncrementalParsing: boolean;
|
2015-02-09 01:10:16 +01:00
|
|
|
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
2015-01-29 20:23:02 +01:00
|
|
|
function createDocumentRegistry(): DocumentRegistry;
|
|
|
|
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
|
|
|
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
|
|
|
function createClassifier(): Classifier;
|
|
|
|
/**
|
|
|
|
* Get the path of the default library file (lib.d.ts) as distributed with the typescript
|
|
|
|
* node package.
|
|
|
|
* The functionality is not supported if the ts module is consumed outside of a node module.
|
|
|
|
*/
|
|
|
|
function getDefaultLibFilePath(options: CompilerOptions): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//// [APISample_transform.js]
|
|
|
|
/*
|
|
|
|
* Note: This test is a public API sample. The sample sources can be found
|
|
|
|
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function
|
|
|
|
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
|
|
|
*/
|
|
|
|
var ts = require("typescript");
|
|
|
|
function transform(contents, compilerOptions) {
|
|
|
|
if (compilerOptions === void 0) { compilerOptions = {}; }
|
|
|
|
// Sources
|
|
|
|
var files = {
|
|
|
|
"file.ts": contents,
|
|
|
|
"lib.d.ts": fs.readFileSync(ts.getDefaultLibFilePath(compilerOptions)).toString()
|
|
|
|
};
|
|
|
|
// Generated outputs
|
|
|
|
var outputs = [];
|
|
|
|
// Create a compilerHost object to allow the compiler to read and write files
|
|
|
|
var compilerHost = {
|
2015-02-04 01:08:46 +01:00
|
|
|
getSourceFile: function (fileName, target) {
|
|
|
|
return files[fileName] !== undefined ? ts.createSourceFile(fileName, files[fileName], target) : undefined;
|
2015-01-29 20:23:02 +01:00
|
|
|
},
|
|
|
|
writeFile: function (name, text, writeByteOrderMark) {
|
|
|
|
outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
|
|
|
|
},
|
2015-02-04 01:08:46 +01:00
|
|
|
getDefaultLibFileName: function () { return "lib.d.ts"; },
|
2015-01-29 20:23:02 +01:00
|
|
|
useCaseSensitiveFileNames: function () { return false; },
|
2015-02-04 01:08:46 +01:00
|
|
|
getCanonicalFileName: function (fileName) { return fileName; },
|
2015-01-29 20:23:02 +01:00
|
|
|
getCurrentDirectory: function () { return ""; },
|
|
|
|
getNewLine: function () { return "\n"; }
|
|
|
|
};
|
|
|
|
// Create a program from inputs
|
|
|
|
var program = ts.createProgram(["file.ts"], compilerOptions, compilerHost);
|
|
|
|
// Query for early errors
|
2015-02-05 10:47:29 +01:00
|
|
|
var errors = ts.getPreEmitDiagnostics(program);
|
|
|
|
var emitResult = program.emit();
|
|
|
|
errors = errors.concat(emitResult.diagnostics);
|
2015-01-29 20:23:02 +01:00
|
|
|
return {
|
|
|
|
outputs: outputs,
|
|
|
|
errors: errors.map(function (e) {
|
2015-02-17 04:55:32 +01:00
|
|
|
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
2015-01-29 20:23:02 +01:00
|
|
|
})
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// Calling our transform function using a simple TypeScript variable declarations,
|
|
|
|
// and loading the default library like:
|
|
|
|
var source = "var x: number = 'string'";
|
|
|
|
var result = transform(source);
|
|
|
|
console.log(JSON.stringify(result));
|