Moved createCompilerHost into parser.ts

Conflicts:
	src/compiler/tsc.ts
This commit is contained in:
Daniel Rosenwasser
2014-12-10 17:13:39 -08:00
parent 77d5d40d20
commit 036209a89e
8 changed files with 965 additions and 699 deletions

View File

@@ -272,6 +272,77 @@ module ts {
}
}
// TODO (drosen, mhegazy): Move to a more appropriate file.
export function createCompilerHost(options: CompilerOptions): CompilerHost {
var currentDirectory: string;
var existingDirectories: Map<boolean> = {};
function getCanonicalFileName(fileName: string): string {
// if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form.
// otherwise use toLowerCase as a canonical form.
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
}
// returned by CScript sys environment
var unsupportedFileEncodingErrorCode = -2147024809;
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
try {
var text = sys.readFile(filename, options.charset);
}
catch (e) {
if (onError) {
onError(e.number === unsupportedFileEncodingErrorCode ?
createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText :
e.message);
}
text = "";
}
return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined;
}
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
var parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}
try {
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
sys.writeFile(fileName, data, writeByteOrderMark);
}
catch (e) {
if (onError) onError(e.message);
}
}
return {
getSourceFile,
getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"),
writeFile,
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
getCanonicalFileName,
getNewLine: () => sys.newLine
};
}
const enum ParsingContext {
SourceElements, // Elements in source file
ModuleElements, // Elements in module declaration

View File

@@ -133,75 +133,6 @@ module ts {
reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
}
function createCompilerHost(options: CompilerOptions): CompilerHost {
var currentDirectory: string;
var existingDirectories: Map<boolean> = {};
function getCanonicalFileName(fileName: string): string {
// if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form.
// otherwise use toLowerCase as a canonical form.
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
}
// returned by CScript sys environment
var unsupportedFileEncodingErrorCode = -2147024809;
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
try {
var text = sys.readFile(filename, options.charset);
}
catch (e) {
if (onError) {
onError(e.number === unsupportedFileEncodingErrorCode ?
getDiagnosticText(Diagnostics.Unsupported_file_encoding) :
e.message);
}
text = "";
}
return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined;
}
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
var parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}
try {
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
sys.writeFile(fileName, data, writeByteOrderMark);
}
catch (e) {
if (onError) onError(e.message);
}
}
return {
getSourceFile,
getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"),
writeFile,
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
getCanonicalFileName,
getNewLine: () => sys.newLine
};
}
export function executeCommandLine(args: string[]): void {
var commandLine = parseCommandLine(args);
var compilerOptions = commandLine.options;

View File

@@ -4,7 +4,7 @@
import ts = require("typescript");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest, "0.0");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest);
var program = ts.createProgram(["file1.ts"], {}, undefined);
//// [typescript.d.ts]
@@ -156,87 +156,92 @@ declare module "typescript" {
ComputedPropertyName = 121,
TypeParameter = 122,
Parameter = 123,
Property = 124,
Method = 125,
Constructor = 126,
GetAccessor = 127,
SetAccessor = 128,
CallSignature = 129,
ConstructSignature = 130,
IndexSignature = 131,
TypeReference = 132,
FunctionType = 133,
ConstructorType = 134,
TypeQuery = 135,
TypeLiteral = 136,
ArrayType = 137,
TupleType = 138,
UnionType = 139,
ParenthesizedType = 140,
ArrayLiteralExpression = 141,
ObjectLiteralExpression = 142,
PropertyAccessExpression = 143,
ElementAccessExpression = 144,
CallExpression = 145,
NewExpression = 146,
TaggedTemplateExpression = 147,
TypeAssertionExpression = 148,
ParenthesizedExpression = 149,
FunctionExpression = 150,
ArrowFunction = 151,
DeleteExpression = 152,
TypeOfExpression = 153,
VoidExpression = 154,
PrefixUnaryExpression = 155,
PostfixUnaryExpression = 156,
BinaryExpression = 157,
ConditionalExpression = 158,
TemplateExpression = 159,
YieldExpression = 160,
OmittedExpression = 161,
TemplateSpan = 162,
Block = 163,
VariableStatement = 164,
EmptyStatement = 165,
ExpressionStatement = 166,
IfStatement = 167,
DoStatement = 168,
WhileStatement = 169,
ForStatement = 170,
ForInStatement = 171,
ContinueStatement = 172,
BreakStatement = 173,
ReturnStatement = 174,
WithStatement = 175,
SwitchStatement = 176,
LabeledStatement = 177,
ThrowStatement = 178,
TryStatement = 179,
TryBlock = 180,
FinallyBlock = 181,
DebuggerStatement = 182,
VariableDeclaration = 183,
FunctionDeclaration = 184,
ClassDeclaration = 185,
InterfaceDeclaration = 186,
TypeAliasDeclaration = 187,
EnumDeclaration = 188,
ModuleDeclaration = 189,
ModuleBlock = 190,
ImportDeclaration = 191,
ExportAssignment = 192,
ExternalModuleReference = 193,
CaseClause = 194,
DefaultClause = 195,
HeritageClause = 196,
CatchClause = 197,
PropertyAssignment = 198,
ShorthandPropertyAssignment = 199,
EnumMember = 200,
SourceFile = 201,
Program = 202,
SyntaxList = 203,
Count = 204,
PropertySignature = 124,
PropertyDeclaration = 125,
MethodSignature = 126,
MethodDeclaration = 127,
Constructor = 128,
GetAccessor = 129,
SetAccessor = 130,
CallSignature = 131,
ConstructSignature = 132,
IndexSignature = 133,
TypeReference = 134,
FunctionType = 135,
ConstructorType = 136,
TypeQuery = 137,
TypeLiteral = 138,
ArrayType = 139,
TupleType = 140,
UnionType = 141,
ParenthesizedType = 142,
ObjectBindingPattern = 143,
ArrayBindingPattern = 144,
BindingElement = 145,
ArrayLiteralExpression = 146,
ObjectLiteralExpression = 147,
PropertyAccessExpression = 148,
ElementAccessExpression = 149,
CallExpression = 150,
NewExpression = 151,
TaggedTemplateExpression = 152,
TypeAssertionExpression = 153,
ParenthesizedExpression = 154,
FunctionExpression = 155,
ArrowFunction = 156,
DeleteExpression = 157,
TypeOfExpression = 158,
VoidExpression = 159,
PrefixUnaryExpression = 160,
PostfixUnaryExpression = 161,
BinaryExpression = 162,
ConditionalExpression = 163,
TemplateExpression = 164,
YieldExpression = 165,
OmittedExpression = 166,
TemplateSpan = 167,
Block = 168,
VariableStatement = 169,
EmptyStatement = 170,
ExpressionStatement = 171,
IfStatement = 172,
DoStatement = 173,
WhileStatement = 174,
ForStatement = 175,
ForInStatement = 176,
ContinueStatement = 177,
BreakStatement = 178,
ReturnStatement = 179,
WithStatement = 180,
SwitchStatement = 181,
LabeledStatement = 182,
ThrowStatement = 183,
TryStatement = 184,
TryBlock = 185,
FinallyBlock = 186,
DebuggerStatement = 187,
VariableDeclaration = 188,
FunctionDeclaration = 189,
ClassDeclaration = 190,
InterfaceDeclaration = 191,
TypeAliasDeclaration = 192,
EnumDeclaration = 193,
ModuleDeclaration = 194,
ModuleBlock = 195,
ImportDeclaration = 196,
ExportAssignment = 197,
ExternalModuleReference = 198,
CaseClause = 199,
DefaultClause = 200,
HeritageClause = 201,
CatchClause = 202,
PropertyAssignment = 203,
ShorthandPropertyAssignment = 204,
EnumMember = 205,
SourceFile = 206,
Program = 207,
SyntaxList = 208,
Count = 209,
FirstAssignment = 51,
LastAssignment = 62,
FirstReservedWord = 64,
@@ -245,8 +250,8 @@ declare module "typescript" {
LastKeyword = 119,
FirstFutureReservedWord = 100,
LastFutureReservedWord = 108,
FirstTypeNode = 132,
LastTypeNode = 140,
FirstTypeNode = 134,
LastTypeNode = 142,
FirstPunctuation = 13,
LastPunctuation = 62,
FirstToken = 0,
@@ -314,7 +319,7 @@ declare module "typescript" {
right: Identifier;
}
type EntityName = Identifier | QualifiedName;
type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName;
type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern;
interface Declaration extends Node {
_declarationBrand: any;
name?: DeclarationName;
@@ -333,38 +338,53 @@ declare module "typescript" {
type?: TypeNode;
}
interface VariableDeclaration extends Declaration {
name: Identifier;
name: Identifier | BindingPattern;
type?: TypeNode;
initializer?: Expression;
}
interface ParameterDeclaration extends Declaration {
dotDotDotToken?: Node;
name: Identifier;
questionToken?: Node;
type?: TypeNode | StringLiteralExpression;
initializer?: Expression;
}
interface PropertyDeclaration extends Declaration, ClassElement {
_propertyDeclarationBrand: any;
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;
}
type VariableOrParameterDeclaration = VariableDeclaration | ParameterDeclaration;
type VariableOrParameterOrPropertyDeclaration = VariableOrParameterDeclaration | PropertyDeclaration;
interface ObjectLiteralElement extends Declaration {
_objectLiteralBrandBrand: any;
}
interface ShorthandPropertyAssignment extends ObjectLiteralElement {
name: Identifier;
questionToken?: Node;
}
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.
@@ -424,6 +444,8 @@ declare module "typescript" {
interface ParenthesizedTypeNode extends TypeNode {
type: TypeNode;
}
interface StringLiteralTypeNode extends LiteralExpression, TypeNode {
}
interface Expression extends Node {
_expressionBrand: any;
contextualType?: Type;
@@ -680,8 +702,6 @@ declare module "typescript" {
nodeCount: number;
identifierCount: number;
symbolCount: number;
isOpen: boolean;
version: string;
languageVersion: ScriptTarget;
identifiers: Map<string>;
}
@@ -831,12 +851,13 @@ declare module "typescript" {
hasSemanticErrors(sourceFile?: SourceFile): boolean;
isDeclarationVisible(node: Declaration): boolean;
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableOrParameterDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
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;
getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number;
isEmitBlocked(sourceFile?: SourceFile): boolean;
isUnknownIdentifier(location: Node, name: string): boolean;
}
const enum SymbolFlags {
FunctionScopedVariable = 1,
@@ -856,54 +877,52 @@ declare module "typescript" {
Constructor = 16384,
GetAccessor = 32768,
SetAccessor = 65536,
CallSignature = 131072,
ConstructSignature = 262144,
IndexSignature = 524288,
TypeParameter = 1048576,
TypeAlias = 2097152,
ExportValue = 4194304,
ExportType = 8388608,
ExportNamespace = 16777216,
Import = 33554432,
Instantiated = 67108864,
Merged = 134217728,
Transient = 268435456,
Prototype = 536870912,
UnionProperty = 1073741824,
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 = 3152352,
Type = 793056,
Namespace = 1536,
Module = 1536,
Accessor = 98304,
Signature = 917504,
FunctionScopedVariableExcludes = 107454,
BlockScopedVariableExcludes = 107455,
ParameterExcludes = 107455,
PropertyExcludes = 107455,
EnumMemberExcludes = 107455,
FunctionExcludes = 106927,
ClassExcludes = 3258879,
InterfaceExcludes = 3152288,
RegularEnumExcludes = 3258623,
ConstEnumExcludes = 3259263,
ClassExcludes = 899583,
InterfaceExcludes = 792992,
RegularEnumExcludes = 899327,
ConstEnumExcludes = 899967,
ValueModuleExcludes = 106639,
NamespaceModuleExcludes = 0,
MethodExcludes = 99263,
GetAccessorExcludes = 41919,
SetAccessorExcludes = 74687,
TypeParameterExcludes = 2103776,
TypeAliasExcludes = 3152352,
ImportExcludes = 33554432,
ModuleMember = 35653619,
TypeParameterExcludes = 530912,
TypeAliasExcludes = 793056,
ImportExcludes = 8388608,
ModuleMember = 8914931,
ExportHasLocal = 944,
HasLocals = 1041936,
HasLocals = 255504,
HasExports = 1952,
HasMembers = 6240,
IsContainer = 1048560,
IsContainer = 262128,
PropertyOrAccessor = 98308,
Export = 29360128,
Export = 7340032,
}
interface Symbol {
flags: SymbolFlags;
@@ -971,6 +990,7 @@ declare module "typescript" {
Union = 16384,
Anonymous = 32768,
FromSignature = 65536,
Unwidened = 131072,
Intrinsic = 127,
StringLike = 258,
NumberLike = 132,
@@ -1338,8 +1358,10 @@ declare module "typescript" {
}
declare module "typescript" {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
function createNode(kind: SyntaxKind): Node;
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T;
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen?: boolean): SourceFile;
function createCompilerHost(options: CompilerOptions): CompilerHost;
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program;
}
declare module "typescript" {
@@ -1388,6 +1410,8 @@ declare module "typescript" {
getDocumentationComment(): SymbolDisplayPart[];
}
interface SourceFile {
isOpen: boolean;
version: string;
getScriptSnapshot(): IScriptSnapshot;
getNamedDeclarations(): Declaration[];
update(scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile;
@@ -1427,6 +1451,8 @@ declare module "typescript" {
}
interface Logger {
log(s: string): void;
trace(s: string): void;
error(s: string): void;
}
interface LanguageServiceHost extends Logger {
getCompilationSettings(): CompilerOptions;
@@ -1850,6 +1876,7 @@ declare module "typescript" {
isCancellationRequested(): boolean;
throwIfCancellationRequested(): void;
}
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile;
function createDocumentRegistry(): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry): LanguageService;
@@ -1859,5 +1886,5 @@ declare module "typescript" {
//// [APISample_node_compile.js]
var ts = require("typescript");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", 2 /* Latest */, "0.0");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", 2 /* Latest */);
var program = ts.createProgram(["file1.ts"], {}, undefined);

View File

@@ -3,12 +3,12 @@
import ts = require("typescript");
>ts : typeof ts
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest, "0.0");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest);
>sourceFile : ts.SourceFile
>ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest, "0.0") : ts.SourceFile
>ts.createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, version: string, isOpen?: boolean) => ts.SourceFile
>ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest) : ts.SourceFile
>ts.createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
>ts : typeof ts
>createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, version: string, isOpen?: boolean) => ts.SourceFile
>createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
>ts.ScriptTarget.Latest : ts.ScriptTarget
>ts.ScriptTarget : typeof ts.ScriptTarget
>ts : typeof ts
@@ -434,247 +434,262 @@ declare module "typescript" {
>NewKeyword : SyntaxKind
NullKeyword = 87,
NullKeyword = 87,
>NullKeyword : SyntaxKind
ReturnKeyword = 88,
ReturnKeyword = 88,
>ReturnKeyword : SyntaxKind
>ReturnKeyword : SyntaxKind
SuperKeyword = 89,
>SuperKeyword : SyntaxKind
SwitchKeyword = 90,
>SwitchKeyword : SyntaxKind
ThisKeyword = 91,
SwitchKeyword = 90,
>ThisKeyword : SyntaxKind
ThrowKeyword = 92,
>ThrowKeyword : SyntaxKind
>ThisKeyword : SyntaxKind
TrueKeyword = 93,
>TrueKeyword : SyntaxKind
TryKeyword = 94,
TrueKeyword = 93,
>TryKeyword : SyntaxKind
TypeOfKeyword = 95,
>TypeOfKeyword : SyntaxKind
>TryKeyword : SyntaxKind
VarKeyword = 96,
>VarKeyword : SyntaxKind
VoidKeyword = 97,
VarKeyword = 96,
>VoidKeyword : SyntaxKind
WhileKeyword = 98,
>WhileKeyword : SyntaxKind
>VoidKeyword : SyntaxKind
WithKeyword = 99,
>WithKeyword : SyntaxKind
ImplementsKeyword = 100,
WithKeyword = 99,
>ImplementsKeyword : SyntaxKind
InterfaceKeyword = 101,
>InterfaceKeyword : SyntaxKind
LetKeyword = 102,
>LetKeyword : SyntaxKind
PackageKeyword = 103,
>PackageKeyword : SyntaxKind
PrivateKeyword = 104,
>ImplementsKeyword : SyntaxKind
>PrivateKeyword : SyntaxKind
ProtectedKeyword = 105,
>ProtectedKeyword : SyntaxKind
LetKeyword = 102,
PublicKeyword = 106,
>PublicKeyword : SyntaxKind
StaticKeyword = 107,
>PackageKeyword : SyntaxKind
>StaticKeyword : SyntaxKind
YieldKeyword = 108,
>YieldKeyword : SyntaxKind
ProtectedKeyword = 105,
AnyKeyword = 109,
>AnyKeyword : SyntaxKind
BooleanKeyword = 110,
>PublicKeyword : SyntaxKind
>BooleanKeyword : SyntaxKind
ConstructorKeyword = 111,
>ConstructorKeyword : SyntaxKind
YieldKeyword = 108,
DeclareKeyword = 112,
>DeclareKeyword : SyntaxKind
GetKeyword = 113,
>AnyKeyword : SyntaxKind
>GetKeyword : SyntaxKind
ModuleKeyword = 114,
>ModuleKeyword : SyntaxKind
ConstructorKeyword = 111,
RequireKeyword = 115,
>RequireKeyword : SyntaxKind
NumberKeyword = 116,
>DeclareKeyword : SyntaxKind
>NumberKeyword : SyntaxKind
SetKeyword = 117,
>SetKeyword : SyntaxKind
ModuleKeyword = 114,
StringKeyword = 118,
>StringKeyword : SyntaxKind
TypeKeyword = 119,
>RequireKeyword : SyntaxKind
>TypeKeyword : SyntaxKind
QualifiedName = 120,
>QualifiedName : SyntaxKind
SetKeyword = 117,
ComputedPropertyName = 121,
>ComputedPropertyName : SyntaxKind
TypeParameter = 122,
>StringKeyword : SyntaxKind
>TypeParameter : SyntaxKind
Parameter = 123,
>Parameter : SyntaxKind
QualifiedName = 120,
PropertySignature = 124,
>PropertySignature : SyntaxKind
PropertyDeclaration = 125,
>ComputedPropertyName : SyntaxKind
>PropertyDeclaration : SyntaxKind
MethodSignature = 126,
>MethodSignature : SyntaxKind
Parameter = 123,
MethodDeclaration = 127,
>MethodDeclaration : SyntaxKind
Constructor = 128,
>Property : SyntaxKind
>Constructor : SyntaxKind
GetAccessor = 129,
>GetAccessor : SyntaxKind
Constructor = 126,
SetAccessor = 130,
>SetAccessor : SyntaxKind
CallSignature = 131,
>GetAccessor : SyntaxKind
>CallSignature : SyntaxKind
ConstructSignature = 132,
>ConstructSignature : SyntaxKind
CallSignature = 129,
IndexSignature = 133,
>IndexSignature : SyntaxKind
TypeReference = 134,
>ConstructSignature : SyntaxKind
>TypeReference : SyntaxKind
FunctionType = 135,
>FunctionType : SyntaxKind
TypeReference = 132,
ConstructorType = 136,
>ConstructorType : SyntaxKind
TypeQuery = 137,
>FunctionType : SyntaxKind
>TypeQuery : SyntaxKind
TypeLiteral = 138,
>TypeLiteral : SyntaxKind
TypeQuery = 135,
ArrayType = 139,
>ArrayType : SyntaxKind
TupleType = 140,
>TypeLiteral : SyntaxKind
>TupleType : SyntaxKind
UnionType = 141,
>UnionType : SyntaxKind
TupleType = 138,
ParenthesizedType = 142,
>ParenthesizedType : SyntaxKind
ObjectBindingPattern = 143,
>UnionType : SyntaxKind
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 144,
>ArrayBindingPattern : SyntaxKind
ArrayLiteralExpression = 141,
BindingElement = 145,
>BindingElement : SyntaxKind
ArrayLiteralExpression = 146,
>ObjectLiteralExpression : SyntaxKind
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 147,
>ObjectLiteralExpression : SyntaxKind
ElementAccessExpression = 144,
PropertyAccessExpression = 148,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 149,
>CallExpression : SyntaxKind
>ElementAccessExpression : SyntaxKind
CallExpression = 150,
>CallExpression : SyntaxKind
TaggedTemplateExpression = 147,
NewExpression = 151,
>NewExpression : SyntaxKind
@@ -701,10 +716,10 @@ declare module "typescript" {
DeleteExpression = 157,
>DeleteExpression : SyntaxKind
TypeOfExpression = 158,
>VoidExpression : SyntaxKind
>TypeOfExpression : SyntaxKind
VoidExpression = 159,
@@ -906,11 +921,12 @@ declare module "typescript" {
SyntaxList = 208,
>SyntaxList : SyntaxKind
FirstAssignment = 51,
Count = 209,
>Count : SyntaxKind
FirstAssignment = 51,
>FirstAssignment : SyntaxKind
@@ -920,8 +936,8 @@ declare module "typescript" {
FirstReservedWord = 64,
>LastReservedWord : SyntaxKind
>FirstReservedWord : SyntaxKind
LastReservedWord = 99,
>LastReservedWord : SyntaxKind
@@ -969,9 +985,10 @@ declare module "typescript" {
FirstTriviaToken = 2,
>FirstTriviaToken : SyntaxKind
FirstLiteralToken = 6,
LastTriviaToken = 5,
>LastTriviaToken : SyntaxKind
FirstLiteralToken = 6,
@@ -989,30 +1006,10 @@ declare module "typescript" {
>LastTemplateToken : SyntaxKind
LastOperator = 62,
FirstOperator = 21,
>FirstOperator : SyntaxKind
>LastOperator : SyntaxKind
FirstBinaryOperator = 23,
>FirstBinaryOperator : SyntaxKind
LastBinaryOperator = 62,
>LastBinaryOperator : SyntaxKind
FirstNode = 120,
>FirstNode : SyntaxKind
}
const enum NodeFlags {
>NodeFlags : NodeFlags
Export = 1,
LastOperator = 62,
>LastOperator : SyntaxKind
@@ -1026,22 +1023,73 @@ declare module "typescript" {
>LastBinaryOperator : SyntaxKind
FirstNode = 120,
Protected = 64,
>Protected : NodeFlags
>FirstNode : SyntaxKind
}
Static = 128,
>Static : NodeFlags
const enum NodeFlags {
>NodeFlags : NodeFlags
Export = 1,
>Export : NodeFlags
Ambient = 2,
>Ambient : NodeFlags
Public = 16,
>Public : NodeFlags
Private = 32,
>Private : NodeFlags
Protected = 64,
>Protected : NodeFlags
Static = 128,
>Static : NodeFlags
MultiLine = 256,
>MultiLine : NodeFlags
Synthetic = 512,
>Synthetic : NodeFlags
DeclarationFile = 1024,
>DeclarationFile : NodeFlags
Let = 2048,
>Let : NodeFlags
Const = 4096,
>Const : NodeFlags
OctalLiteral = 8192,
>OctalLiteral : NodeFlags
Modifier = 243,
>Modifier : NodeFlags
AccessibilityModifier = 112,
>AccessibilityModifier : NodeFlags
BlockScoped = 6144,
>BlockScoped : NodeFlags
}
const enum ParserContextFlags {
@@ -1055,24 +1103,42 @@ declare module "typescript" {
DisallowIn = 2,
>DisallowIn : ParserContextFlags
OctalLiteral = 8192,
>OctalLiteral : NodeFlags
Yield = 4,
>Yield : ParserContextFlags
Modifier = 243,
GeneratorParameter = 8,
>GeneratorParameter : ParserContextFlags
ContainsError = 16,
>ContainsError : ParserContextFlags
AccessibilityModifier = 112,
HasPropagatedChildContainsErrorFlag = 32,
>HasPropagatedChildContainsErrorFlag : ParserContextFlags
}
interface Node extends TextRange {
}
>Node : Node
>TextRange : TextRange
kind: SyntaxKind;
>kind : SyntaxKind
>SyntaxKind : SyntaxKind
flags: NodeFlags;
>flags : NodeFlags
>NodeFlags : NodeFlags
parserContextFlags?: ParserContextFlags;
>parserContextFlags : ParserContextFlags
>ParserContextFlags : ParserContextFlags
id?: number;
@@ -1233,6 +1299,11 @@ declare module "typescript" {
>TypeParameterDeclaration : TypeParameterDeclaration
parameters: NodeArray<ParameterDeclaration>;
>parameters : NodeArray<ParameterDeclaration>
>NodeArray : NodeArray<T>
>ParameterDeclaration : ParameterDeclaration
type?: TypeNode;
>type : TypeNode
@@ -1859,8 +1930,8 @@ declare module "typescript" {
>whenFalse : Expression
>Expression : Expression
>LiteralExpression : LiteralExpression
>PrimaryExpression : PrimaryExpression
}
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration {
>FunctionExpression : FunctionExpression
@@ -2028,12 +2099,6 @@ declare module "typescript" {
}
interface NewExpression extends CallExpression, PrimaryExpression {
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression;
>CallLikeExpression : CallExpression | NewExpression | TaggedTemplateExpression
>CallExpression : CallExpression
>NewExpression : NewExpression
>NewExpression : NewExpression
>CallExpression : CallExpression
@@ -2674,11 +2739,11 @@ declare module "typescript" {
>amdDependencies : string[]
amdModuleName: string;
semanticDiagnostics: Diagnostic[];
>semanticDiagnostics : Diagnostic[]
>amdModuleName : string
referencedFiles: FileReference[];
>referencedFiles : FileReference[]
>FileReference : FileReference
@@ -2725,6 +2790,12 @@ declare module "typescript" {
>identifierCount : number
symbolCount: number;
>symbolCount : number
languageVersion: ScriptTarget;
>languageVersion : ScriptTarget
>ScriptTarget : ScriptTarget
identifiers: Map<string>;
@@ -2780,48 +2851,45 @@ declare module "typescript" {
>getCommonSourceDirectory : () => string
}
>sourceLine : number
interface SourceMapSpan {
sourceColumn: number;
>sourceColumn : number
nameIndex?: number;
>nameIndex : number
>SourceMapSpan : SourceMapSpan
emittedLine: number;
>emittedLine : number
emittedColumn: number;
>emittedColumn : number
>SourceMapData : SourceMapData
sourceLine: number;
>sourceLine : number
sourceColumn: number;
jsSourceMappingURL: string;
>sourceColumn : number
nameIndex?: number;
>nameIndex : number
>sourceMapFile : string
sourceIndex: number;
>sourceIndex : number
}
sourceMapSources: string[];
interface SourceMapData {
>SourceMapData : SourceMapData
sourceMapFilePath: string;
>sourceMapFilePath : string
jsSourceMappingURL: string;
>jsSourceMappingURL : string
@@ -2831,7 +2899,7 @@ declare module "typescript" {
sourceMapSourceRoot: string;
>sourceMapSourceRoot : string
sourceMapSources: string[];
@@ -2843,9 +2911,6 @@ declare module "typescript" {
sourceMapNames?: string[];
>Succeeded : EmitReturnStatus
>sourceMapNames : string[]
sourceMapMappings: string;
@@ -2864,16 +2929,16 @@ declare module "typescript" {
Succeeded = 0,
>CompilerOptionsErrors : EmitReturnStatus
>Succeeded : EmitReturnStatus
AllOutputGenerationSkipped = 1,
interface EmitResult {
>AllOutputGenerationSkipped : EmitReturnStatus
JSGeneratedWithSemanticErrors = 2,
>JSGeneratedWithSemanticErrors : EmitReturnStatus
>emitResultStatus : EmitReturnStatus
DeclarationGenerationSkipped = 3,
>DeclarationGenerationSkipped : EmitReturnStatus
@@ -2891,22 +2956,22 @@ declare module "typescript" {
>EmitResult : EmitResult
getProgram(): Program;
emitResultStatus: EmitReturnStatus;
>emitResultStatus : EmitReturnStatus
>Program : Program
>EmitReturnStatus : EmitReturnStatus
diagnostics: Diagnostic[];
>diagnostics : Diagnostic[]
>Diagnostic : Diagnostic
>SourceFile : SourceFile
sourceMaps: SourceMapData[];
>sourceMaps : SourceMapData[]
>SourceMapData : SourceMapData
}
>sourceFile : SourceFile
interface TypeChecker {
>TypeChecker : TypeChecker
@@ -2915,13 +2980,13 @@ declare module "typescript" {
>getProgram : () => Program
>Program : Program
getNodeCount(): number;
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
>sourceFile : SourceFile
>SourceFile : SourceFile
>getIdentifierCount : () => number
>Diagnostic : Diagnostic
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
@@ -3125,6 +3190,9 @@ declare module "typescript" {
>Symbol : Symbol
isArgumentsSymbol(symbol: Symbol): boolean;
>isArgumentsSymbol : (symbol: Symbol) => boolean
>symbol : Symbol
>Symbol : Symbol
isEmitBlocked(sourceFile?: SourceFile): boolean;
@@ -4242,6 +4310,12 @@ declare module "typescript" {
openReferenceTargets: GenericType[];
>openReferenceTargets : GenericType[]
>GenericType : GenericType
openReferenceChecks: Map<boolean>;
>openReferenceChecks : Map<boolean>
>Map : Map<T>
}
interface TupleType extends ObjectType {
@@ -4259,14 +4333,19 @@ declare module "typescript" {
>baseArrayType : TypeReference
>TypeReference : TypeReference
}
>SymbolTable : SymbolTable
}
interface UnionType extends Type {
>UnionType : UnionType
>Type : Type
types: Type[];
>types : Type[]
>Type : Type
resolvedProperties: SymbolTable;
>ObjectType : ObjectType
>UnionType : UnionType
>resolvedProperties : SymbolTable
>SymbolTable : SymbolTable
}
@@ -4445,6 +4524,12 @@ declare module "typescript" {
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
@@ -4529,6 +4614,14 @@ declare module "typescript" {
messageText: string;
>messageText : string
category: DiagnosticCategory;
>category : DiagnosticCategory
>DiagnosticCategory : DiagnosticCategory
code: number;
>code : number
@@ -5713,6 +5806,18 @@ declare module "typescript" {
>getFirstToken : (sourceFile?: SourceFile) => Node
>sourceFile : SourceFile
>SourceFile : SourceFile
>Node : Node
getLastToken(sourceFile?: SourceFile): Node;
>getLastToken : (sourceFile?: SourceFile) => Node
>sourceFile : SourceFile
>SourceFile : SourceFile
>Node : Node
}
interface Symbol {
>Symbol : Symbol

View File

@@ -2,7 +2,7 @@
//// [APISample_standalone_compile.ts]
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest, "0.0");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest);
var program = ts.createProgram(["file1.ts"], {}, undefined);
//// [typescriptServices.d.ts]
@@ -154,87 +154,92 @@ declare module ts {
ComputedPropertyName = 121,
TypeParameter = 122,
Parameter = 123,
Property = 124,
Method = 125,
Constructor = 126,
GetAccessor = 127,
SetAccessor = 128,
CallSignature = 129,
ConstructSignature = 130,
IndexSignature = 131,
TypeReference = 132,
FunctionType = 133,
ConstructorType = 134,
TypeQuery = 135,
TypeLiteral = 136,
ArrayType = 137,
TupleType = 138,
UnionType = 139,
ParenthesizedType = 140,
ArrayLiteralExpression = 141,
ObjectLiteralExpression = 142,
PropertyAccessExpression = 143,
ElementAccessExpression = 144,
CallExpression = 145,
NewExpression = 146,
TaggedTemplateExpression = 147,
TypeAssertionExpression = 148,
ParenthesizedExpression = 149,
FunctionExpression = 150,
ArrowFunction = 151,
DeleteExpression = 152,
TypeOfExpression = 153,
VoidExpression = 154,
PrefixUnaryExpression = 155,
PostfixUnaryExpression = 156,
BinaryExpression = 157,
ConditionalExpression = 158,
TemplateExpression = 159,
YieldExpression = 160,
OmittedExpression = 161,
TemplateSpan = 162,
Block = 163,
VariableStatement = 164,
EmptyStatement = 165,
ExpressionStatement = 166,
IfStatement = 167,
DoStatement = 168,
WhileStatement = 169,
ForStatement = 170,
ForInStatement = 171,
ContinueStatement = 172,
BreakStatement = 173,
ReturnStatement = 174,
WithStatement = 175,
SwitchStatement = 176,
LabeledStatement = 177,
ThrowStatement = 178,
TryStatement = 179,
TryBlock = 180,
FinallyBlock = 181,
DebuggerStatement = 182,
VariableDeclaration = 183,
FunctionDeclaration = 184,
ClassDeclaration = 185,
InterfaceDeclaration = 186,
TypeAliasDeclaration = 187,
EnumDeclaration = 188,
ModuleDeclaration = 189,
ModuleBlock = 190,
ImportDeclaration = 191,
ExportAssignment = 192,
ExternalModuleReference = 193,
CaseClause = 194,
DefaultClause = 195,
HeritageClause = 196,
CatchClause = 197,
PropertyAssignment = 198,
ShorthandPropertyAssignment = 199,
EnumMember = 200,
SourceFile = 201,
Program = 202,
SyntaxList = 203,
Count = 204,
PropertySignature = 124,
PropertyDeclaration = 125,
MethodSignature = 126,
MethodDeclaration = 127,
Constructor = 128,
GetAccessor = 129,
SetAccessor = 130,
CallSignature = 131,
ConstructSignature = 132,
IndexSignature = 133,
TypeReference = 134,
FunctionType = 135,
ConstructorType = 136,
TypeQuery = 137,
TypeLiteral = 138,
ArrayType = 139,
TupleType = 140,
UnionType = 141,
ParenthesizedType = 142,
ObjectBindingPattern = 143,
ArrayBindingPattern = 144,
BindingElement = 145,
ArrayLiteralExpression = 146,
ObjectLiteralExpression = 147,
PropertyAccessExpression = 148,
ElementAccessExpression = 149,
CallExpression = 150,
NewExpression = 151,
TaggedTemplateExpression = 152,
TypeAssertionExpression = 153,
ParenthesizedExpression = 154,
FunctionExpression = 155,
ArrowFunction = 156,
DeleteExpression = 157,
TypeOfExpression = 158,
VoidExpression = 159,
PrefixUnaryExpression = 160,
PostfixUnaryExpression = 161,
BinaryExpression = 162,
ConditionalExpression = 163,
TemplateExpression = 164,
YieldExpression = 165,
OmittedExpression = 166,
TemplateSpan = 167,
Block = 168,
VariableStatement = 169,
EmptyStatement = 170,
ExpressionStatement = 171,
IfStatement = 172,
DoStatement = 173,
WhileStatement = 174,
ForStatement = 175,
ForInStatement = 176,
ContinueStatement = 177,
BreakStatement = 178,
ReturnStatement = 179,
WithStatement = 180,
SwitchStatement = 181,
LabeledStatement = 182,
ThrowStatement = 183,
TryStatement = 184,
TryBlock = 185,
FinallyBlock = 186,
DebuggerStatement = 187,
VariableDeclaration = 188,
FunctionDeclaration = 189,
ClassDeclaration = 190,
InterfaceDeclaration = 191,
TypeAliasDeclaration = 192,
EnumDeclaration = 193,
ModuleDeclaration = 194,
ModuleBlock = 195,
ImportDeclaration = 196,
ExportAssignment = 197,
ExternalModuleReference = 198,
CaseClause = 199,
DefaultClause = 200,
HeritageClause = 201,
CatchClause = 202,
PropertyAssignment = 203,
ShorthandPropertyAssignment = 204,
EnumMember = 205,
SourceFile = 206,
Program = 207,
SyntaxList = 208,
Count = 209,
FirstAssignment = 51,
LastAssignment = 62,
FirstReservedWord = 64,
@@ -243,8 +248,8 @@ declare module ts {
LastKeyword = 119,
FirstFutureReservedWord = 100,
LastFutureReservedWord = 108,
FirstTypeNode = 132,
LastTypeNode = 140,
FirstTypeNode = 134,
LastTypeNode = 142,
FirstPunctuation = 13,
LastPunctuation = 62,
FirstToken = 0,
@@ -312,7 +317,7 @@ declare module ts {
right: Identifier;
}
type EntityName = Identifier | QualifiedName;
type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName;
type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern;
interface Declaration extends Node {
_declarationBrand: any;
name?: DeclarationName;
@@ -331,38 +336,53 @@ declare module ts {
type?: TypeNode;
}
interface VariableDeclaration extends Declaration {
name: Identifier;
name: Identifier | BindingPattern;
type?: TypeNode;
initializer?: Expression;
}
interface ParameterDeclaration extends Declaration {
dotDotDotToken?: Node;
name: Identifier;
questionToken?: Node;
type?: TypeNode | StringLiteralExpression;
initializer?: Expression;
}
interface PropertyDeclaration extends Declaration, ClassElement {
_propertyDeclarationBrand: any;
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;
}
type VariableOrParameterDeclaration = VariableDeclaration | ParameterDeclaration;
type VariableOrParameterOrPropertyDeclaration = VariableOrParameterDeclaration | PropertyDeclaration;
interface ObjectLiteralElement extends Declaration {
_objectLiteralBrandBrand: any;
}
interface ShorthandPropertyAssignment extends ObjectLiteralElement {
name: Identifier;
questionToken?: Node;
}
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.
@@ -422,6 +442,8 @@ declare module ts {
interface ParenthesizedTypeNode extends TypeNode {
type: TypeNode;
}
interface StringLiteralTypeNode extends LiteralExpression, TypeNode {
}
interface Expression extends Node {
_expressionBrand: any;
contextualType?: Type;
@@ -678,8 +700,6 @@ declare module ts {
nodeCount: number;
identifierCount: number;
symbolCount: number;
isOpen: boolean;
version: string;
languageVersion: ScriptTarget;
identifiers: Map<string>;
}
@@ -829,12 +849,13 @@ declare module ts {
hasSemanticErrors(sourceFile?: SourceFile): boolean;
isDeclarationVisible(node: Declaration): boolean;
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableOrParameterDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
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;
getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number;
isEmitBlocked(sourceFile?: SourceFile): boolean;
isUnknownIdentifier(location: Node, name: string): boolean;
}
const enum SymbolFlags {
FunctionScopedVariable = 1,
@@ -854,54 +875,52 @@ declare module ts {
Constructor = 16384,
GetAccessor = 32768,
SetAccessor = 65536,
CallSignature = 131072,
ConstructSignature = 262144,
IndexSignature = 524288,
TypeParameter = 1048576,
TypeAlias = 2097152,
ExportValue = 4194304,
ExportType = 8388608,
ExportNamespace = 16777216,
Import = 33554432,
Instantiated = 67108864,
Merged = 134217728,
Transient = 268435456,
Prototype = 536870912,
UnionProperty = 1073741824,
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 = 3152352,
Type = 793056,
Namespace = 1536,
Module = 1536,
Accessor = 98304,
Signature = 917504,
FunctionScopedVariableExcludes = 107454,
BlockScopedVariableExcludes = 107455,
ParameterExcludes = 107455,
PropertyExcludes = 107455,
EnumMemberExcludes = 107455,
FunctionExcludes = 106927,
ClassExcludes = 3258879,
InterfaceExcludes = 3152288,
RegularEnumExcludes = 3258623,
ConstEnumExcludes = 3259263,
ClassExcludes = 899583,
InterfaceExcludes = 792992,
RegularEnumExcludes = 899327,
ConstEnumExcludes = 899967,
ValueModuleExcludes = 106639,
NamespaceModuleExcludes = 0,
MethodExcludes = 99263,
GetAccessorExcludes = 41919,
SetAccessorExcludes = 74687,
TypeParameterExcludes = 2103776,
TypeAliasExcludes = 3152352,
ImportExcludes = 33554432,
ModuleMember = 35653619,
TypeParameterExcludes = 530912,
TypeAliasExcludes = 793056,
ImportExcludes = 8388608,
ModuleMember = 8914931,
ExportHasLocal = 944,
HasLocals = 1041936,
HasLocals = 255504,
HasExports = 1952,
HasMembers = 6240,
IsContainer = 1048560,
IsContainer = 262128,
PropertyOrAccessor = 98308,
Export = 29360128,
Export = 7340032,
}
interface Symbol {
flags: SymbolFlags;
@@ -969,6 +988,7 @@ declare module ts {
Union = 16384,
Anonymous = 32768,
FromSignature = 65536,
Unwidened = 131072,
Intrinsic = 127,
StringLike = 258,
NumberLike = 132,
@@ -1336,8 +1356,10 @@ declare module ts {
}
declare module ts {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
function createNode(kind: SyntaxKind): Node;
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T;
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen?: boolean): SourceFile;
function createCompilerHost(options: CompilerOptions): CompilerHost;
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program;
}
declare module ts {
@@ -1386,6 +1408,8 @@ declare module ts {
getDocumentationComment(): SymbolDisplayPart[];
}
interface SourceFile {
isOpen: boolean;
version: string;
getScriptSnapshot(): IScriptSnapshot;
getNamedDeclarations(): Declaration[];
update(scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile;
@@ -1425,6 +1449,8 @@ declare module ts {
}
interface Logger {
log(s: string): void;
trace(s: string): void;
error(s: string): void;
}
interface LanguageServiceHost extends Logger {
getCompilationSettings(): CompilerOptions;
@@ -1848,6 +1874,7 @@ declare module ts {
isCancellationRequested(): boolean;
throwIfCancellationRequested(): void;
}
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile;
function createDocumentRegistry(): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry): LanguageService;
@@ -1856,5 +1883,5 @@ declare module ts {
//// [APISample_standalone_compile.js]
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", 2 /* Latest */, "0.0");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", 2 /* Latest */);
var program = ts.createProgram(["file1.ts"], {}, undefined);

View File

@@ -1,11 +1,11 @@
=== tests/cases/compiler/APISample_standalone_compile.ts ===
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest, "0.0");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest);
>sourceFile : ts.SourceFile
>ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest, "0.0") : ts.SourceFile
>ts.createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, version: string, isOpen?: boolean) => ts.SourceFile
>ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest) : ts.SourceFile
>ts.createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
>ts : typeof ts
>createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, version: string, isOpen?: boolean) => ts.SourceFile
>createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
>ts.ScriptTarget.Latest : ts.ScriptTarget
>ts.ScriptTarget : typeof ts.ScriptTarget
>ts : typeof ts
@@ -433,247 +433,262 @@ declare module ts {
>NewKeyword : SyntaxKind
NullKeyword = 87,
NullKeyword = 87,
>NullKeyword : SyntaxKind
ReturnKeyword = 88,
ReturnKeyword = 88,
>ReturnKeyword : SyntaxKind
>ReturnKeyword : SyntaxKind
SuperKeyword = 89,
>SuperKeyword : SyntaxKind
SwitchKeyword = 90,
>SwitchKeyword : SyntaxKind
ThisKeyword = 91,
SwitchKeyword = 90,
>ThisKeyword : SyntaxKind
ThrowKeyword = 92,
>ThrowKeyword : SyntaxKind
>ThisKeyword : SyntaxKind
TrueKeyword = 93,
>TrueKeyword : SyntaxKind
TryKeyword = 94,
TrueKeyword = 93,
>TryKeyword : SyntaxKind
TypeOfKeyword = 95,
>TypeOfKeyword : SyntaxKind
>TryKeyword : SyntaxKind
VarKeyword = 96,
>VarKeyword : SyntaxKind
VoidKeyword = 97,
VarKeyword = 96,
>VoidKeyword : SyntaxKind
WhileKeyword = 98,
>WhileKeyword : SyntaxKind
>VoidKeyword : SyntaxKind
WithKeyword = 99,
>WithKeyword : SyntaxKind
ImplementsKeyword = 100,
WithKeyword = 99,
>ImplementsKeyword : SyntaxKind
InterfaceKeyword = 101,
>InterfaceKeyword : SyntaxKind
LetKeyword = 102,
>LetKeyword : SyntaxKind
PackageKeyword = 103,
>PackageKeyword : SyntaxKind
PrivateKeyword = 104,
>ImplementsKeyword : SyntaxKind
>PrivateKeyword : SyntaxKind
ProtectedKeyword = 105,
>ProtectedKeyword : SyntaxKind
LetKeyword = 102,
PublicKeyword = 106,
>PublicKeyword : SyntaxKind
StaticKeyword = 107,
>PackageKeyword : SyntaxKind
>StaticKeyword : SyntaxKind
YieldKeyword = 108,
>YieldKeyword : SyntaxKind
ProtectedKeyword = 105,
AnyKeyword = 109,
>AnyKeyword : SyntaxKind
BooleanKeyword = 110,
>PublicKeyword : SyntaxKind
>BooleanKeyword : SyntaxKind
ConstructorKeyword = 111,
>ConstructorKeyword : SyntaxKind
YieldKeyword = 108,
DeclareKeyword = 112,
>DeclareKeyword : SyntaxKind
GetKeyword = 113,
>AnyKeyword : SyntaxKind
>GetKeyword : SyntaxKind
ModuleKeyword = 114,
>ModuleKeyword : SyntaxKind
ConstructorKeyword = 111,
RequireKeyword = 115,
>RequireKeyword : SyntaxKind
NumberKeyword = 116,
>DeclareKeyword : SyntaxKind
>NumberKeyword : SyntaxKind
SetKeyword = 117,
>SetKeyword : SyntaxKind
ModuleKeyword = 114,
StringKeyword = 118,
>StringKeyword : SyntaxKind
TypeKeyword = 119,
>RequireKeyword : SyntaxKind
>TypeKeyword : SyntaxKind
QualifiedName = 120,
>QualifiedName : SyntaxKind
SetKeyword = 117,
ComputedPropertyName = 121,
>ComputedPropertyName : SyntaxKind
TypeParameter = 122,
>StringKeyword : SyntaxKind
>TypeParameter : SyntaxKind
Parameter = 123,
>Parameter : SyntaxKind
QualifiedName = 120,
PropertySignature = 124,
>PropertySignature : SyntaxKind
PropertyDeclaration = 125,
>ComputedPropertyName : SyntaxKind
>PropertyDeclaration : SyntaxKind
MethodSignature = 126,
>MethodSignature : SyntaxKind
Parameter = 123,
MethodDeclaration = 127,
>MethodDeclaration : SyntaxKind
Constructor = 128,
>Property : SyntaxKind
>Constructor : SyntaxKind
GetAccessor = 129,
>GetAccessor : SyntaxKind
Constructor = 126,
SetAccessor = 130,
>SetAccessor : SyntaxKind
CallSignature = 131,
>GetAccessor : SyntaxKind
>CallSignature : SyntaxKind
ConstructSignature = 132,
>ConstructSignature : SyntaxKind
CallSignature = 129,
IndexSignature = 133,
>IndexSignature : SyntaxKind
TypeReference = 134,
>ConstructSignature : SyntaxKind
>TypeReference : SyntaxKind
FunctionType = 135,
>FunctionType : SyntaxKind
TypeReference = 132,
ConstructorType = 136,
>ConstructorType : SyntaxKind
TypeQuery = 137,
>FunctionType : SyntaxKind
>TypeQuery : SyntaxKind
TypeLiteral = 138,
>TypeLiteral : SyntaxKind
TypeQuery = 135,
ArrayType = 139,
>ArrayType : SyntaxKind
TupleType = 140,
>TypeLiteral : SyntaxKind
>TupleType : SyntaxKind
UnionType = 141,
>UnionType : SyntaxKind
TupleType = 138,
ParenthesizedType = 142,
>ParenthesizedType : SyntaxKind
ObjectBindingPattern = 143,
>UnionType : SyntaxKind
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 144,
>ArrayBindingPattern : SyntaxKind
ArrayLiteralExpression = 141,
BindingElement = 145,
>BindingElement : SyntaxKind
ArrayLiteralExpression = 146,
>ObjectLiteralExpression : SyntaxKind
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 147,
>ObjectLiteralExpression : SyntaxKind
ElementAccessExpression = 144,
PropertyAccessExpression = 148,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 149,
>CallExpression : SyntaxKind
>ElementAccessExpression : SyntaxKind
CallExpression = 150,
>CallExpression : SyntaxKind
TaggedTemplateExpression = 147,
NewExpression = 151,
>NewExpression : SyntaxKind
@@ -700,10 +715,10 @@ declare module ts {
DeleteExpression = 157,
>DeleteExpression : SyntaxKind
TypeOfExpression = 158,
>VoidExpression : SyntaxKind
>TypeOfExpression : SyntaxKind
VoidExpression = 159,
@@ -905,11 +920,12 @@ declare module ts {
SyntaxList = 208,
>SyntaxList : SyntaxKind
FirstAssignment = 51,
Count = 209,
>Count : SyntaxKind
FirstAssignment = 51,
>FirstAssignment : SyntaxKind
@@ -919,8 +935,8 @@ declare module ts {
FirstReservedWord = 64,
>LastReservedWord : SyntaxKind
>FirstReservedWord : SyntaxKind
LastReservedWord = 99,
>LastReservedWord : SyntaxKind
@@ -968,9 +984,10 @@ declare module ts {
FirstTriviaToken = 2,
>FirstTriviaToken : SyntaxKind
FirstLiteralToken = 6,
LastTriviaToken = 5,
>LastTriviaToken : SyntaxKind
FirstLiteralToken = 6,
@@ -988,30 +1005,10 @@ declare module ts {
>LastTemplateToken : SyntaxKind
LastOperator = 62,
FirstOperator = 21,
>FirstOperator : SyntaxKind
>LastOperator : SyntaxKind
FirstBinaryOperator = 23,
>FirstBinaryOperator : SyntaxKind
LastBinaryOperator = 62,
>LastBinaryOperator : SyntaxKind
FirstNode = 120,
>FirstNode : SyntaxKind
}
const enum NodeFlags {
>NodeFlags : NodeFlags
Export = 1,
LastOperator = 62,
>LastOperator : SyntaxKind
@@ -1025,22 +1022,73 @@ declare module ts {
>LastBinaryOperator : SyntaxKind
FirstNode = 120,
Protected = 64,
>Protected : NodeFlags
>FirstNode : SyntaxKind
}
Static = 128,
>Static : NodeFlags
const enum NodeFlags {
>NodeFlags : NodeFlags
Export = 1,
>Export : NodeFlags
Ambient = 2,
>Ambient : NodeFlags
Public = 16,
>Public : NodeFlags
Private = 32,
>Private : NodeFlags
Protected = 64,
>Protected : NodeFlags
Static = 128,
>Static : NodeFlags
MultiLine = 256,
>MultiLine : NodeFlags
Synthetic = 512,
>Synthetic : NodeFlags
DeclarationFile = 1024,
>DeclarationFile : NodeFlags
Let = 2048,
>Let : NodeFlags
Const = 4096,
>Const : NodeFlags
OctalLiteral = 8192,
>OctalLiteral : NodeFlags
Modifier = 243,
>Modifier : NodeFlags
AccessibilityModifier = 112,
>AccessibilityModifier : NodeFlags
BlockScoped = 6144,
>BlockScoped : NodeFlags
}
const enum ParserContextFlags {
@@ -1054,24 +1102,42 @@ declare module ts {
DisallowIn = 2,
>DisallowIn : ParserContextFlags
OctalLiteral = 8192,
>OctalLiteral : NodeFlags
Yield = 4,
>Yield : ParserContextFlags
Modifier = 243,
GeneratorParameter = 8,
>GeneratorParameter : ParserContextFlags
ContainsError = 16,
>ContainsError : ParserContextFlags
AccessibilityModifier = 112,
HasPropagatedChildContainsErrorFlag = 32,
>HasPropagatedChildContainsErrorFlag : ParserContextFlags
}
interface Node extends TextRange {
}
>Node : Node
>TextRange : TextRange
kind: SyntaxKind;
>kind : SyntaxKind
>SyntaxKind : SyntaxKind
flags: NodeFlags;
>flags : NodeFlags
>NodeFlags : NodeFlags
parserContextFlags?: ParserContextFlags;
>parserContextFlags : ParserContextFlags
>ParserContextFlags : ParserContextFlags
id?: number;
@@ -1232,6 +1298,11 @@ declare module ts {
>TypeParameterDeclaration : TypeParameterDeclaration
parameters: NodeArray<ParameterDeclaration>;
>parameters : NodeArray<ParameterDeclaration>
>NodeArray : NodeArray<T>
>ParameterDeclaration : ParameterDeclaration
type?: TypeNode;
>type : TypeNode
@@ -1858,8 +1929,8 @@ declare module ts {
>whenFalse : Expression
>Expression : Expression
>LiteralExpression : LiteralExpression
>PrimaryExpression : PrimaryExpression
}
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration {
>FunctionExpression : FunctionExpression
@@ -2027,12 +2098,6 @@ declare module ts {
}
interface NewExpression extends CallExpression, PrimaryExpression {
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression;
>CallLikeExpression : CallExpression | NewExpression | TaggedTemplateExpression
>CallExpression : CallExpression
>NewExpression : NewExpression
>NewExpression : NewExpression
>CallExpression : CallExpression
@@ -2673,11 +2738,11 @@ declare module ts {
>amdDependencies : string[]
amdModuleName: string;
semanticDiagnostics: Diagnostic[];
>semanticDiagnostics : Diagnostic[]
>amdModuleName : string
referencedFiles: FileReference[];
>referencedFiles : FileReference[]
>FileReference : FileReference
@@ -2724,6 +2789,12 @@ declare module ts {
>identifierCount : number
symbolCount: number;
>symbolCount : number
languageVersion: ScriptTarget;
>languageVersion : ScriptTarget
>ScriptTarget : ScriptTarget
identifiers: Map<string>;
@@ -2779,48 +2850,45 @@ declare module ts {
>getCommonSourceDirectory : () => string
}
>sourceLine : number
interface SourceMapSpan {
sourceColumn: number;
>sourceColumn : number
nameIndex?: number;
>nameIndex : number
>SourceMapSpan : SourceMapSpan
emittedLine: number;
>emittedLine : number
emittedColumn: number;
>emittedColumn : number
>SourceMapData : SourceMapData
sourceLine: number;
>sourceLine : number
sourceColumn: number;
jsSourceMappingURL: string;
>sourceColumn : number
nameIndex?: number;
>nameIndex : number
>sourceMapFile : string
sourceIndex: number;
>sourceIndex : number
}
sourceMapSources: string[];
interface SourceMapData {
>SourceMapData : SourceMapData
sourceMapFilePath: string;
>sourceMapFilePath : string
jsSourceMappingURL: string;
>jsSourceMappingURL : string
@@ -2830,7 +2898,7 @@ declare module ts {
sourceMapSourceRoot: string;
>sourceMapSourceRoot : string
sourceMapSources: string[];
@@ -2842,9 +2910,6 @@ declare module ts {
sourceMapNames?: string[];
>Succeeded : EmitReturnStatus
>sourceMapNames : string[]
sourceMapMappings: string;
@@ -2863,16 +2928,16 @@ declare module ts {
Succeeded = 0,
>CompilerOptionsErrors : EmitReturnStatus
>Succeeded : EmitReturnStatus
AllOutputGenerationSkipped = 1,
interface EmitResult {
>AllOutputGenerationSkipped : EmitReturnStatus
JSGeneratedWithSemanticErrors = 2,
>JSGeneratedWithSemanticErrors : EmitReturnStatus
>emitResultStatus : EmitReturnStatus
DeclarationGenerationSkipped = 3,
>DeclarationGenerationSkipped : EmitReturnStatus
@@ -2890,22 +2955,22 @@ declare module ts {
>EmitResult : EmitResult
getProgram(): Program;
emitResultStatus: EmitReturnStatus;
>emitResultStatus : EmitReturnStatus
>Program : Program
>EmitReturnStatus : EmitReturnStatus
diagnostics: Diagnostic[];
>diagnostics : Diagnostic[]
>Diagnostic : Diagnostic
>SourceFile : SourceFile
sourceMaps: SourceMapData[];
>sourceMaps : SourceMapData[]
>SourceMapData : SourceMapData
}
>sourceFile : SourceFile
interface TypeChecker {
>TypeChecker : TypeChecker
@@ -2914,13 +2979,13 @@ declare module ts {
>getProgram : () => Program
>Program : Program
getNodeCount(): number;
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
>sourceFile : SourceFile
>SourceFile : SourceFile
>getIdentifierCount : () => number
>Diagnostic : Diagnostic
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
@@ -3124,6 +3189,9 @@ declare module ts {
>Symbol : Symbol
isArgumentsSymbol(symbol: Symbol): boolean;
>isArgumentsSymbol : (symbol: Symbol) => boolean
>symbol : Symbol
>Symbol : Symbol
isEmitBlocked(sourceFile?: SourceFile): boolean;
@@ -4245,6 +4313,12 @@ declare module ts {
openReferenceChecks: Map<boolean>;
>openReferenceChecks : Map<boolean>
>Map : Map<T>
}
interface TupleType extends ObjectType {
>TupleType : TupleType
>ObjectType : ObjectType
@@ -4262,14 +4336,19 @@ declare module ts {
interface UnionType extends Type {
>UnionType : UnionType
>ResolvedType : ResolvedType
>Type : Type
types: Type[];
>types : Type[]
>Type : Type
resolvedProperties: SymbolTable;
>resolvedProperties : SymbolTable
>SymbolTable : SymbolTable
}
>members : SymbolTable
interface ResolvedType extends ObjectType, UnionType {
>ResolvedType : ResolvedType
@@ -4452,6 +4531,12 @@ declare module ts {
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
@@ -4536,6 +4621,14 @@ declare module ts {
>DiagnosticCategory : DiagnosticCategory
code: number;
>code : number
/**
* Early error - any error (can be produced at parsing\binding\typechecking step) that blocks emit
*/
isEarly?: boolean;
@@ -5720,6 +5813,18 @@ declare module ts {
>getFirstToken : (sourceFile?: SourceFile) => Node
>sourceFile : SourceFile
>SourceFile : SourceFile
>Node : Node
getLastToken(sourceFile?: SourceFile): Node;
>getLastToken : (sourceFile?: SourceFile) => Node
>sourceFile : SourceFile
>SourceFile : SourceFile
>Node : Node
}
interface Symbol {
>Symbol : Symbol

View File

@@ -6,6 +6,6 @@
import ts = require("typescript");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest, "0.0");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest);
var program = ts.createProgram(["file1.ts"], {}, undefined);

View File

@@ -2,6 +2,6 @@
// @noImplicitAny: true
// @target: ES3
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest, "0.0");
var sourceFile = ts.createSourceFile("file1.ts", "var x = 0;", ts.ScriptTarget.Latest);
var program = ts.createProgram(["file1.ts"], {}, undefined);