diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d2a5971a078..b8ddaedf67f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -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 = {}; + + 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 diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 54d80d31190..5e4918d91e9 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -133,75 +133,6 @@ module ts { reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); } - function createCompilerHost(options: CompilerOptions): CompilerHost { - var currentDirectory: string; - var existingDirectories: Map = {}; - - 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; diff --git a/tests/baselines/reference/APISample_node_compile.js b/tests/baselines/reference/APISample_node_compile.js index 6807d97db84..223ba05429d 100644 --- a/tests/baselines/reference/APISample_node_compile.js +++ b/tests/baselines/reference/APISample_node_compile.js @@ -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; + } /** * 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; } @@ -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(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); diff --git a/tests/baselines/reference/APISample_node_compile.types b/tests/baselines/reference/APISample_node_compile.types index 4331fb28c72..fa881875212 100644 --- a/tests/baselines/reference/APISample_node_compile.types +++ b/tests/baselines/reference/APISample_node_compile.types @@ -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" { Parameter = 123, >Parameter : SyntaxKind - Property = 124, ->Property : SyntaxKind + PropertySignature = 124, +>PropertySignature : SyntaxKind - Method = 125, ->Method : SyntaxKind + PropertyDeclaration = 125, +>PropertyDeclaration : SyntaxKind - Constructor = 126, + MethodSignature = 126, +>MethodSignature : SyntaxKind + + MethodDeclaration = 127, +>MethodDeclaration : SyntaxKind + + Constructor = 128, >Constructor : SyntaxKind - GetAccessor = 127, + GetAccessor = 129, >GetAccessor : SyntaxKind - SetAccessor = 128, + SetAccessor = 130, >SetAccessor : SyntaxKind - CallSignature = 129, + CallSignature = 131, >CallSignature : SyntaxKind - ConstructSignature = 130, + ConstructSignature = 132, >ConstructSignature : SyntaxKind - IndexSignature = 131, + IndexSignature = 133, >IndexSignature : SyntaxKind - TypeReference = 132, + TypeReference = 134, >TypeReference : SyntaxKind - FunctionType = 133, + FunctionType = 135, >FunctionType : SyntaxKind - ConstructorType = 134, + ConstructorType = 136, >ConstructorType : SyntaxKind - TypeQuery = 135, + TypeQuery = 137, >TypeQuery : SyntaxKind - TypeLiteral = 136, + TypeLiteral = 138, >TypeLiteral : SyntaxKind - ArrayType = 137, + ArrayType = 139, >ArrayType : SyntaxKind - TupleType = 138, + TupleType = 140, >TupleType : SyntaxKind - UnionType = 139, + UnionType = 141, >UnionType : SyntaxKind - ParenthesizedType = 140, + ParenthesizedType = 142, >ParenthesizedType : SyntaxKind - ArrayLiteralExpression = 141, + ObjectBindingPattern = 143, +>ObjectBindingPattern : SyntaxKind + + ArrayBindingPattern = 144, +>ArrayBindingPattern : SyntaxKind + + BindingElement = 145, +>BindingElement : SyntaxKind + + ArrayLiteralExpression = 146, >ArrayLiteralExpression : SyntaxKind - ObjectLiteralExpression = 142, + ObjectLiteralExpression = 147, >ObjectLiteralExpression : SyntaxKind - PropertyAccessExpression = 143, + PropertyAccessExpression = 148, >PropertyAccessExpression : SyntaxKind - ElementAccessExpression = 144, + ElementAccessExpression = 149, >ElementAccessExpression : SyntaxKind - CallExpression = 145, + CallExpression = 150, >CallExpression : SyntaxKind - NewExpression = 146, + NewExpression = 151, >NewExpression : SyntaxKind - TaggedTemplateExpression = 147, + TaggedTemplateExpression = 152, >TaggedTemplateExpression : SyntaxKind - TypeAssertionExpression = 148, + TypeAssertionExpression = 153, >TypeAssertionExpression : SyntaxKind - ParenthesizedExpression = 149, + ParenthesizedExpression = 154, >ParenthesizedExpression : SyntaxKind - FunctionExpression = 150, + FunctionExpression = 155, >FunctionExpression : SyntaxKind - ArrowFunction = 151, + ArrowFunction = 156, >ArrowFunction : SyntaxKind - DeleteExpression = 152, + DeleteExpression = 157, >DeleteExpression : SyntaxKind - TypeOfExpression = 153, + TypeOfExpression = 158, >TypeOfExpression : SyntaxKind - VoidExpression = 154, + VoidExpression = 159, >VoidExpression : SyntaxKind - PrefixUnaryExpression = 155, + PrefixUnaryExpression = 160, >PrefixUnaryExpression : SyntaxKind - PostfixUnaryExpression = 156, + PostfixUnaryExpression = 161, >PostfixUnaryExpression : SyntaxKind - BinaryExpression = 157, + BinaryExpression = 162, >BinaryExpression : SyntaxKind - ConditionalExpression = 158, + ConditionalExpression = 163, >ConditionalExpression : SyntaxKind - TemplateExpression = 159, + TemplateExpression = 164, >TemplateExpression : SyntaxKind - YieldExpression = 160, + YieldExpression = 165, >YieldExpression : SyntaxKind - OmittedExpression = 161, + OmittedExpression = 166, >OmittedExpression : SyntaxKind - TemplateSpan = 162, + TemplateSpan = 167, >TemplateSpan : SyntaxKind - Block = 163, + Block = 168, >Block : SyntaxKind - VariableStatement = 164, + VariableStatement = 169, >VariableStatement : SyntaxKind - EmptyStatement = 165, + EmptyStatement = 170, >EmptyStatement : SyntaxKind - ExpressionStatement = 166, + ExpressionStatement = 171, >ExpressionStatement : SyntaxKind - IfStatement = 167, + IfStatement = 172, >IfStatement : SyntaxKind - DoStatement = 168, + DoStatement = 173, >DoStatement : SyntaxKind - WhileStatement = 169, + WhileStatement = 174, >WhileStatement : SyntaxKind - ForStatement = 170, + ForStatement = 175, >ForStatement : SyntaxKind - ForInStatement = 171, + ForInStatement = 176, >ForInStatement : SyntaxKind - ContinueStatement = 172, + ContinueStatement = 177, >ContinueStatement : SyntaxKind - BreakStatement = 173, + BreakStatement = 178, >BreakStatement : SyntaxKind - ReturnStatement = 174, + ReturnStatement = 179, >ReturnStatement : SyntaxKind - WithStatement = 175, + WithStatement = 180, >WithStatement : SyntaxKind - SwitchStatement = 176, + SwitchStatement = 181, >SwitchStatement : SyntaxKind - LabeledStatement = 177, + LabeledStatement = 182, >LabeledStatement : SyntaxKind - ThrowStatement = 178, + ThrowStatement = 183, >ThrowStatement : SyntaxKind - TryStatement = 179, + TryStatement = 184, >TryStatement : SyntaxKind - TryBlock = 180, + TryBlock = 185, >TryBlock : SyntaxKind - FinallyBlock = 181, + FinallyBlock = 186, >FinallyBlock : SyntaxKind - DebuggerStatement = 182, + DebuggerStatement = 187, >DebuggerStatement : SyntaxKind - VariableDeclaration = 183, + VariableDeclaration = 188, >VariableDeclaration : SyntaxKind - FunctionDeclaration = 184, + FunctionDeclaration = 189, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 185, + ClassDeclaration = 190, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 186, + InterfaceDeclaration = 191, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 187, + TypeAliasDeclaration = 192, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 188, + EnumDeclaration = 193, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 189, + ModuleDeclaration = 194, >ModuleDeclaration : SyntaxKind - ModuleBlock = 190, + ModuleBlock = 195, >ModuleBlock : SyntaxKind - ImportDeclaration = 191, + ImportDeclaration = 196, >ImportDeclaration : SyntaxKind - ExportAssignment = 192, + ExportAssignment = 197, >ExportAssignment : SyntaxKind - ExternalModuleReference = 193, + ExternalModuleReference = 198, >ExternalModuleReference : SyntaxKind - CaseClause = 194, + CaseClause = 199, >CaseClause : SyntaxKind - DefaultClause = 195, + DefaultClause = 200, >DefaultClause : SyntaxKind - HeritageClause = 196, + HeritageClause = 201, >HeritageClause : SyntaxKind - CatchClause = 197, + CatchClause = 202, >CatchClause : SyntaxKind - PropertyAssignment = 198, + PropertyAssignment = 203, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 199, + ShorthandPropertyAssignment = 204, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 200, + EnumMember = 205, >EnumMember : SyntaxKind - SourceFile = 201, + SourceFile = 206, >SourceFile : SyntaxKind - Program = 202, + Program = 207, >Program : SyntaxKind - SyntaxList = 203, + SyntaxList = 208, >SyntaxList : SyntaxKind - Count = 204, + Count = 209, >Count : SyntaxKind FirstAssignment = 51, @@ -701,10 +716,10 @@ declare module "typescript" { LastFutureReservedWord = 108, >LastFutureReservedWord : SyntaxKind - FirstTypeNode = 132, + FirstTypeNode = 134, >FirstTypeNode : SyntaxKind - LastTypeNode = 140, + LastTypeNode = 142, >LastTypeNode : SyntaxKind FirstPunctuation = 13, @@ -906,11 +921,12 @@ declare module "typescript" { >Identifier : Identifier >QualifiedName : QualifiedName - type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName; ->DeclarationName : Identifier | LiteralExpression | ComputedPropertyName + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern >Identifier : Identifier >LiteralExpression : LiteralExpression >ComputedPropertyName : ComputedPropertyName +>BindingPattern : BindingPattern interface Declaration extends Node { >Declaration : Declaration @@ -920,8 +936,8 @@ declare module "typescript" { >_declarationBrand : any name?: DeclarationName; ->name : Identifier | LiteralExpression | ComputedPropertyName ->DeclarationName : Identifier | LiteralExpression | ComputedPropertyName +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern } interface ComputedPropertyName extends Node { >ComputedPropertyName : ComputedPropertyName @@ -969,9 +985,10 @@ declare module "typescript" { >VariableDeclaration : VariableDeclaration >Declaration : Declaration - name: Identifier; ->name : Identifier + name: Identifier | BindingPattern; +>name : Identifier | BindingPattern >Identifier : Identifier +>BindingPattern : BindingPattern type?: TypeNode; >type : TypeNode @@ -989,30 +1006,10 @@ declare module "typescript" { >dotDotDotToken : Node >Node : Node - name: Identifier; ->name : Identifier + name: Identifier | BindingPattern; +>name : Identifier | BindingPattern >Identifier : Identifier - - questionToken?: Node; ->questionToken : Node ->Node : Node - - type?: TypeNode | StringLiteralExpression; ->type : TypeNode | StringLiteralExpression ->TypeNode : TypeNode ->StringLiteralExpression : StringLiteralExpression - - initializer?: Expression; ->initializer : Expression ->Expression : Expression - } - interface PropertyDeclaration extends Declaration, ClassElement { ->PropertyDeclaration : PropertyDeclaration ->Declaration : Declaration ->ClassElement : ClassElement - - _propertyDeclarationBrand: any; ->_propertyDeclarationBrand : any +>BindingPattern : BindingPattern questionToken?: Node; >questionToken : Node @@ -1026,22 +1023,73 @@ declare module "typescript" { >initializer : Expression >Expression : Expression } - type VariableOrParameterDeclaration = VariableDeclaration | ParameterDeclaration; ->VariableOrParameterDeclaration : ParameterDeclaration | VariableDeclaration ->VariableDeclaration : VariableDeclaration ->ParameterDeclaration : ParameterDeclaration + interface BindingElement extends Declaration { +>BindingElement : BindingElement +>Declaration : Declaration - type VariableOrParameterOrPropertyDeclaration = VariableOrParameterDeclaration | PropertyDeclaration; ->VariableOrParameterOrPropertyDeclaration : ParameterDeclaration | VariableDeclaration | PropertyDeclaration ->VariableOrParameterDeclaration : ParameterDeclaration | VariableDeclaration + propertyName?: Identifier; +>propertyName : Identifier +>Identifier : Identifier + + dotDotDotToken?: Node; +>dotDotDotToken : Node +>Node : Node + + name: Identifier | BindingPattern; +>name : Identifier | BindingPattern +>Identifier : Identifier +>BindingPattern : BindingPattern + + initializer?: Expression; +>initializer : Expression +>Expression : Expression + } + interface PropertyDeclaration extends Declaration, ClassElement { >PropertyDeclaration : PropertyDeclaration +>Declaration : Declaration +>ClassElement : ClassElement + name: DeclarationName; +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern + + questionToken?: Node; +>questionToken : Node +>Node : Node + + type?: TypeNode; +>type : TypeNode +>TypeNode : TypeNode + + initializer?: Expression; +>initializer : Expression +>Expression : Expression + } interface ObjectLiteralElement extends Declaration { >ObjectLiteralElement : ObjectLiteralElement >Declaration : Declaration _objectLiteralBrandBrand: any; >_objectLiteralBrandBrand : any + } + interface PropertyAssignment extends ObjectLiteralElement { +>PropertyAssignment : PropertyAssignment +>ObjectLiteralElement : ObjectLiteralElement + + _propertyAssignmentBrand: any; +>_propertyAssignmentBrand : any + + name: DeclarationName; +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern + + questionToken?: Node; +>questionToken : Node +>Node : Node + + initializer: Expression; +>initializer : Expression +>Expression : Expression } interface ShorthandPropertyAssignment extends ObjectLiteralElement { >ShorthandPropertyAssignment : ShorthandPropertyAssignment @@ -1055,24 +1103,42 @@ declare module "typescript" { >questionToken : Node >Node : Node } - interface PropertyAssignment extends ObjectLiteralElement { ->PropertyAssignment : PropertyAssignment ->ObjectLiteralElement : ObjectLiteralElement + interface VariableLikeDeclaration extends Declaration { +>VariableLikeDeclaration : VariableLikeDeclaration +>Declaration : Declaration - _propertyAssignmentBrand: any; ->_propertyAssignmentBrand : any + propertyName?: Identifier; +>propertyName : Identifier +>Identifier : Identifier + + dotDotDotToken?: Node; +>dotDotDotToken : Node +>Node : Node name: DeclarationName; ->name : Identifier | LiteralExpression | ComputedPropertyName ->DeclarationName : Identifier | LiteralExpression | ComputedPropertyName +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern questionToken?: Node; >questionToken : Node >Node : Node - initializer: Expression; + type?: TypeNode; +>type : TypeNode +>TypeNode : TypeNode + + initializer?: Expression; >initializer : Expression >Expression : Expression + } + interface BindingPattern extends Node { +>BindingPattern : BindingPattern +>Node : Node + + elements: NodeArray; +>elements : NodeArray +>NodeArray : NodeArray +>BindingElement : BindingElement } /** * Several node kinds share function-like features such as a signature, @@ -1233,6 +1299,11 @@ declare module "typescript" { type: TypeNode; >type : TypeNode +>TypeNode : TypeNode + } + interface StringLiteralTypeNode extends LiteralExpression, TypeNode { +>StringLiteralTypeNode : StringLiteralTypeNode +>LiteralExpression : LiteralExpression >TypeNode : TypeNode } interface Expression extends Node { @@ -1859,8 +1930,8 @@ declare module "typescript" { >Declaration : Declaration name: DeclarationName; ->name : Identifier | LiteralExpression | ComputedPropertyName ->DeclarationName : Identifier | LiteralExpression | ComputedPropertyName +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern initializer?: Expression; >initializer : Expression @@ -2028,12 +2099,6 @@ declare module "typescript" { symbolCount: number; >symbolCount : number - isOpen: boolean; ->isOpen : boolean - - version: string; ->version : string - languageVersion: ScriptTarget; >languageVersion : ScriptTarget >ScriptTarget : ScriptTarget @@ -2674,11 +2739,11 @@ declare module "typescript" { >node : FunctionLikeDeclaration >FunctionLikeDeclaration : FunctionLikeDeclaration - writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableOrParameterDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; ->writeTypeOfDeclaration : (declaration: ParameterDeclaration | VariableDeclaration | AccessorDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) => void ->declaration : ParameterDeclaration | VariableDeclaration | AccessorDeclaration + writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; +>writeTypeOfDeclaration : (declaration: VariableLikeDeclaration | AccessorDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) => void +>declaration : VariableLikeDeclaration | AccessorDeclaration >AccessorDeclaration : AccessorDeclaration ->VariableOrParameterDeclaration : ParameterDeclaration | VariableDeclaration +>VariableLikeDeclaration : VariableLikeDeclaration >enclosingDeclaration : Node >Node : Node >flags : TypeFormatFlags @@ -2725,6 +2790,12 @@ declare module "typescript" { >isEmitBlocked : (sourceFile?: SourceFile) => boolean >sourceFile : SourceFile >SourceFile : SourceFile + + isUnknownIdentifier(location: Node, name: string): boolean; +>isUnknownIdentifier : (location: Node, name: string) => boolean +>location : Node +>Node : Node +>name : string } const enum SymbolFlags { >SymbolFlags : SymbolFlags @@ -2780,48 +2851,45 @@ declare module "typescript" { SetAccessor = 65536, >SetAccessor : SymbolFlags - CallSignature = 131072, ->CallSignature : SymbolFlags + Signature = 131072, +>Signature : SymbolFlags - ConstructSignature = 262144, ->ConstructSignature : SymbolFlags - - IndexSignature = 524288, ->IndexSignature : SymbolFlags - - TypeParameter = 1048576, + TypeParameter = 262144, >TypeParameter : SymbolFlags - TypeAlias = 2097152, + TypeAlias = 524288, >TypeAlias : SymbolFlags - ExportValue = 4194304, + ExportValue = 1048576, >ExportValue : SymbolFlags - ExportType = 8388608, + ExportType = 2097152, >ExportType : SymbolFlags - ExportNamespace = 16777216, + ExportNamespace = 4194304, >ExportNamespace : SymbolFlags - Import = 33554432, + Import = 8388608, >Import : SymbolFlags - Instantiated = 67108864, + Instantiated = 16777216, >Instantiated : SymbolFlags - Merged = 134217728, + Merged = 33554432, >Merged : SymbolFlags - Transient = 268435456, + Transient = 67108864, >Transient : SymbolFlags - Prototype = 536870912, + Prototype = 134217728, >Prototype : SymbolFlags - UnionProperty = 1073741824, + UnionProperty = 268435456, >UnionProperty : SymbolFlags + Optional = 536870912, +>Optional : SymbolFlags + Enum = 384, >Enum : SymbolFlags @@ -2831,7 +2899,7 @@ declare module "typescript" { Value = 107455, >Value : SymbolFlags - Type = 3152352, + Type = 793056, >Type : SymbolFlags Namespace = 1536, @@ -2843,9 +2911,6 @@ declare module "typescript" { Accessor = 98304, >Accessor : SymbolFlags - Signature = 917504, ->Signature : SymbolFlags - FunctionScopedVariableExcludes = 107454, >FunctionScopedVariableExcludes : SymbolFlags @@ -2864,16 +2929,16 @@ declare module "typescript" { FunctionExcludes = 106927, >FunctionExcludes : SymbolFlags - ClassExcludes = 3258879, + ClassExcludes = 899583, >ClassExcludes : SymbolFlags - InterfaceExcludes = 3152288, + InterfaceExcludes = 792992, >InterfaceExcludes : SymbolFlags - RegularEnumExcludes = 3258623, + RegularEnumExcludes = 899327, >RegularEnumExcludes : SymbolFlags - ConstEnumExcludes = 3259263, + ConstEnumExcludes = 899967, >ConstEnumExcludes : SymbolFlags ValueModuleExcludes = 106639, @@ -2891,22 +2956,22 @@ declare module "typescript" { SetAccessorExcludes = 74687, >SetAccessorExcludes : SymbolFlags - TypeParameterExcludes = 2103776, + TypeParameterExcludes = 530912, >TypeParameterExcludes : SymbolFlags - TypeAliasExcludes = 3152352, + TypeAliasExcludes = 793056, >TypeAliasExcludes : SymbolFlags - ImportExcludes = 33554432, + ImportExcludes = 8388608, >ImportExcludes : SymbolFlags - ModuleMember = 35653619, + ModuleMember = 8914931, >ModuleMember : SymbolFlags ExportHasLocal = 944, >ExportHasLocal : SymbolFlags - HasLocals = 1041936, + HasLocals = 255504, >HasLocals : SymbolFlags HasExports = 1952, @@ -2915,13 +2980,13 @@ declare module "typescript" { HasMembers = 6240, >HasMembers : SymbolFlags - IsContainer = 1048560, + IsContainer = 262128, >IsContainer : SymbolFlags PropertyOrAccessor = 98308, >PropertyOrAccessor : SymbolFlags - Export = 29360128, + Export = 7340032, >Export : SymbolFlags } interface Symbol { @@ -3125,6 +3190,9 @@ declare module "typescript" { FromSignature = 65536, >FromSignature : TypeFlags + Unwidened = 131072, +>Unwidened : TypeFlags + Intrinsic = 127, >Intrinsic : TypeFlags @@ -4242,6 +4310,12 @@ declare module "typescript" { >getNodeConstructor : (kind: SyntaxKind) => new () => Node >kind : SyntaxKind >SyntaxKind : SyntaxKind +>Node : Node + + function createNode(kind: SyntaxKind): Node; +>createNode : (kind: SyntaxKind) => Node +>kind : SyntaxKind +>SyntaxKind : SyntaxKind >Node : Node function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T; @@ -4259,14 +4333,19 @@ declare module "typescript" { >T : T >T : T - function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen?: boolean): SourceFile; ->createSourceFile : (filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen?: boolean) => SourceFile + function createCompilerHost(options: CompilerOptions): CompilerHost; +>createCompilerHost : (options: CompilerOptions) => CompilerHost +>options : CompilerOptions +>CompilerOptions : CompilerOptions +>CompilerHost : CompilerHost + + function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; +>createSourceFile : (filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile >filename : string >sourceText : string >languageVersion : ScriptTarget >ScriptTarget : ScriptTarget ->version : string ->isOpen : boolean +>setParentNodes : boolean >SourceFile : SourceFile function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program; @@ -4445,6 +4524,12 @@ declare module "typescript" { interface SourceFile { >SourceFile : SourceFile + isOpen: boolean; +>isOpen : boolean + + version: string; +>version : string + getScriptSnapshot(): IScriptSnapshot; >getScriptSnapshot : () => IScriptSnapshot >IScriptSnapshot : IScriptSnapshot @@ -4529,6 +4614,14 @@ declare module "typescript" { log(s: string): void; >log : (s: string) => void +>s : string + + trace(s: string): void; +>trace : (s: string) => void +>s : string + + error(s: string): void; +>error : (s: string) => void >s : string } interface LanguageServiceHost extends Logger { @@ -5713,6 +5806,18 @@ declare module "typescript" { throwIfCancellationRequested(): void; >throwIfCancellationRequested : () => void } + function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile; +>createLanguageServiceSourceFile : (filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean) => SourceFile +>filename : string +>scriptSnapshot : IScriptSnapshot +>IScriptSnapshot : IScriptSnapshot +>scriptTarget : ScriptTarget +>ScriptTarget : ScriptTarget +>version : string +>isOpen : boolean +>setNodeParents : boolean +>SourceFile : SourceFile + function createDocumentRegistry(): DocumentRegistry; >createDocumentRegistry : () => DocumentRegistry >DocumentRegistry : DocumentRegistry diff --git a/tests/baselines/reference/APISample_standalone_compile.js b/tests/baselines/reference/APISample_standalone_compile.js index fff2226f320..c885aa03c54 100644 --- a/tests/baselines/reference/APISample_standalone_compile.js +++ b/tests/baselines/reference/APISample_standalone_compile.js @@ -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; + } /** * 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; } @@ -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(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); diff --git a/tests/baselines/reference/APISample_standalone_compile.types b/tests/baselines/reference/APISample_standalone_compile.types index c69e655aec1..804aa67e64e 100644 --- a/tests/baselines/reference/APISample_standalone_compile.types +++ b/tests/baselines/reference/APISample_standalone_compile.types @@ -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 { Parameter = 123, >Parameter : SyntaxKind - Property = 124, ->Property : SyntaxKind + PropertySignature = 124, +>PropertySignature : SyntaxKind - Method = 125, ->Method : SyntaxKind + PropertyDeclaration = 125, +>PropertyDeclaration : SyntaxKind - Constructor = 126, + MethodSignature = 126, +>MethodSignature : SyntaxKind + + MethodDeclaration = 127, +>MethodDeclaration : SyntaxKind + + Constructor = 128, >Constructor : SyntaxKind - GetAccessor = 127, + GetAccessor = 129, >GetAccessor : SyntaxKind - SetAccessor = 128, + SetAccessor = 130, >SetAccessor : SyntaxKind - CallSignature = 129, + CallSignature = 131, >CallSignature : SyntaxKind - ConstructSignature = 130, + ConstructSignature = 132, >ConstructSignature : SyntaxKind - IndexSignature = 131, + IndexSignature = 133, >IndexSignature : SyntaxKind - TypeReference = 132, + TypeReference = 134, >TypeReference : SyntaxKind - FunctionType = 133, + FunctionType = 135, >FunctionType : SyntaxKind - ConstructorType = 134, + ConstructorType = 136, >ConstructorType : SyntaxKind - TypeQuery = 135, + TypeQuery = 137, >TypeQuery : SyntaxKind - TypeLiteral = 136, + TypeLiteral = 138, >TypeLiteral : SyntaxKind - ArrayType = 137, + ArrayType = 139, >ArrayType : SyntaxKind - TupleType = 138, + TupleType = 140, >TupleType : SyntaxKind - UnionType = 139, + UnionType = 141, >UnionType : SyntaxKind - ParenthesizedType = 140, + ParenthesizedType = 142, >ParenthesizedType : SyntaxKind - ArrayLiteralExpression = 141, + ObjectBindingPattern = 143, +>ObjectBindingPattern : SyntaxKind + + ArrayBindingPattern = 144, +>ArrayBindingPattern : SyntaxKind + + BindingElement = 145, +>BindingElement : SyntaxKind + + ArrayLiteralExpression = 146, >ArrayLiteralExpression : SyntaxKind - ObjectLiteralExpression = 142, + ObjectLiteralExpression = 147, >ObjectLiteralExpression : SyntaxKind - PropertyAccessExpression = 143, + PropertyAccessExpression = 148, >PropertyAccessExpression : SyntaxKind - ElementAccessExpression = 144, + ElementAccessExpression = 149, >ElementAccessExpression : SyntaxKind - CallExpression = 145, + CallExpression = 150, >CallExpression : SyntaxKind - NewExpression = 146, + NewExpression = 151, >NewExpression : SyntaxKind - TaggedTemplateExpression = 147, + TaggedTemplateExpression = 152, >TaggedTemplateExpression : SyntaxKind - TypeAssertionExpression = 148, + TypeAssertionExpression = 153, >TypeAssertionExpression : SyntaxKind - ParenthesizedExpression = 149, + ParenthesizedExpression = 154, >ParenthesizedExpression : SyntaxKind - FunctionExpression = 150, + FunctionExpression = 155, >FunctionExpression : SyntaxKind - ArrowFunction = 151, + ArrowFunction = 156, >ArrowFunction : SyntaxKind - DeleteExpression = 152, + DeleteExpression = 157, >DeleteExpression : SyntaxKind - TypeOfExpression = 153, + TypeOfExpression = 158, >TypeOfExpression : SyntaxKind - VoidExpression = 154, + VoidExpression = 159, >VoidExpression : SyntaxKind - PrefixUnaryExpression = 155, + PrefixUnaryExpression = 160, >PrefixUnaryExpression : SyntaxKind - PostfixUnaryExpression = 156, + PostfixUnaryExpression = 161, >PostfixUnaryExpression : SyntaxKind - BinaryExpression = 157, + BinaryExpression = 162, >BinaryExpression : SyntaxKind - ConditionalExpression = 158, + ConditionalExpression = 163, >ConditionalExpression : SyntaxKind - TemplateExpression = 159, + TemplateExpression = 164, >TemplateExpression : SyntaxKind - YieldExpression = 160, + YieldExpression = 165, >YieldExpression : SyntaxKind - OmittedExpression = 161, + OmittedExpression = 166, >OmittedExpression : SyntaxKind - TemplateSpan = 162, + TemplateSpan = 167, >TemplateSpan : SyntaxKind - Block = 163, + Block = 168, >Block : SyntaxKind - VariableStatement = 164, + VariableStatement = 169, >VariableStatement : SyntaxKind - EmptyStatement = 165, + EmptyStatement = 170, >EmptyStatement : SyntaxKind - ExpressionStatement = 166, + ExpressionStatement = 171, >ExpressionStatement : SyntaxKind - IfStatement = 167, + IfStatement = 172, >IfStatement : SyntaxKind - DoStatement = 168, + DoStatement = 173, >DoStatement : SyntaxKind - WhileStatement = 169, + WhileStatement = 174, >WhileStatement : SyntaxKind - ForStatement = 170, + ForStatement = 175, >ForStatement : SyntaxKind - ForInStatement = 171, + ForInStatement = 176, >ForInStatement : SyntaxKind - ContinueStatement = 172, + ContinueStatement = 177, >ContinueStatement : SyntaxKind - BreakStatement = 173, + BreakStatement = 178, >BreakStatement : SyntaxKind - ReturnStatement = 174, + ReturnStatement = 179, >ReturnStatement : SyntaxKind - WithStatement = 175, + WithStatement = 180, >WithStatement : SyntaxKind - SwitchStatement = 176, + SwitchStatement = 181, >SwitchStatement : SyntaxKind - LabeledStatement = 177, + LabeledStatement = 182, >LabeledStatement : SyntaxKind - ThrowStatement = 178, + ThrowStatement = 183, >ThrowStatement : SyntaxKind - TryStatement = 179, + TryStatement = 184, >TryStatement : SyntaxKind - TryBlock = 180, + TryBlock = 185, >TryBlock : SyntaxKind - FinallyBlock = 181, + FinallyBlock = 186, >FinallyBlock : SyntaxKind - DebuggerStatement = 182, + DebuggerStatement = 187, >DebuggerStatement : SyntaxKind - VariableDeclaration = 183, + VariableDeclaration = 188, >VariableDeclaration : SyntaxKind - FunctionDeclaration = 184, + FunctionDeclaration = 189, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 185, + ClassDeclaration = 190, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 186, + InterfaceDeclaration = 191, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 187, + TypeAliasDeclaration = 192, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 188, + EnumDeclaration = 193, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 189, + ModuleDeclaration = 194, >ModuleDeclaration : SyntaxKind - ModuleBlock = 190, + ModuleBlock = 195, >ModuleBlock : SyntaxKind - ImportDeclaration = 191, + ImportDeclaration = 196, >ImportDeclaration : SyntaxKind - ExportAssignment = 192, + ExportAssignment = 197, >ExportAssignment : SyntaxKind - ExternalModuleReference = 193, + ExternalModuleReference = 198, >ExternalModuleReference : SyntaxKind - CaseClause = 194, + CaseClause = 199, >CaseClause : SyntaxKind - DefaultClause = 195, + DefaultClause = 200, >DefaultClause : SyntaxKind - HeritageClause = 196, + HeritageClause = 201, >HeritageClause : SyntaxKind - CatchClause = 197, + CatchClause = 202, >CatchClause : SyntaxKind - PropertyAssignment = 198, + PropertyAssignment = 203, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 199, + ShorthandPropertyAssignment = 204, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 200, + EnumMember = 205, >EnumMember : SyntaxKind - SourceFile = 201, + SourceFile = 206, >SourceFile : SyntaxKind - Program = 202, + Program = 207, >Program : SyntaxKind - SyntaxList = 203, + SyntaxList = 208, >SyntaxList : SyntaxKind - Count = 204, + Count = 209, >Count : SyntaxKind FirstAssignment = 51, @@ -700,10 +715,10 @@ declare module ts { LastFutureReservedWord = 108, >LastFutureReservedWord : SyntaxKind - FirstTypeNode = 132, + FirstTypeNode = 134, >FirstTypeNode : SyntaxKind - LastTypeNode = 140, + LastTypeNode = 142, >LastTypeNode : SyntaxKind FirstPunctuation = 13, @@ -905,11 +920,12 @@ declare module ts { >Identifier : Identifier >QualifiedName : QualifiedName - type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName; ->DeclarationName : Identifier | LiteralExpression | ComputedPropertyName + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern >Identifier : Identifier >LiteralExpression : LiteralExpression >ComputedPropertyName : ComputedPropertyName +>BindingPattern : BindingPattern interface Declaration extends Node { >Declaration : Declaration @@ -919,8 +935,8 @@ declare module ts { >_declarationBrand : any name?: DeclarationName; ->name : Identifier | LiteralExpression | ComputedPropertyName ->DeclarationName : Identifier | LiteralExpression | ComputedPropertyName +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern } interface ComputedPropertyName extends Node { >ComputedPropertyName : ComputedPropertyName @@ -968,9 +984,10 @@ declare module ts { >VariableDeclaration : VariableDeclaration >Declaration : Declaration - name: Identifier; ->name : Identifier + name: Identifier | BindingPattern; +>name : Identifier | BindingPattern >Identifier : Identifier +>BindingPattern : BindingPattern type?: TypeNode; >type : TypeNode @@ -988,30 +1005,10 @@ declare module ts { >dotDotDotToken : Node >Node : Node - name: Identifier; ->name : Identifier + name: Identifier | BindingPattern; +>name : Identifier | BindingPattern >Identifier : Identifier - - questionToken?: Node; ->questionToken : Node ->Node : Node - - type?: TypeNode | StringLiteralExpression; ->type : TypeNode | StringLiteralExpression ->TypeNode : TypeNode ->StringLiteralExpression : StringLiteralExpression - - initializer?: Expression; ->initializer : Expression ->Expression : Expression - } - interface PropertyDeclaration extends Declaration, ClassElement { ->PropertyDeclaration : PropertyDeclaration ->Declaration : Declaration ->ClassElement : ClassElement - - _propertyDeclarationBrand: any; ->_propertyDeclarationBrand : any +>BindingPattern : BindingPattern questionToken?: Node; >questionToken : Node @@ -1025,22 +1022,73 @@ declare module ts { >initializer : Expression >Expression : Expression } - type VariableOrParameterDeclaration = VariableDeclaration | ParameterDeclaration; ->VariableOrParameterDeclaration : ParameterDeclaration | VariableDeclaration ->VariableDeclaration : VariableDeclaration ->ParameterDeclaration : ParameterDeclaration + interface BindingElement extends Declaration { +>BindingElement : BindingElement +>Declaration : Declaration - type VariableOrParameterOrPropertyDeclaration = VariableOrParameterDeclaration | PropertyDeclaration; ->VariableOrParameterOrPropertyDeclaration : ParameterDeclaration | VariableDeclaration | PropertyDeclaration ->VariableOrParameterDeclaration : ParameterDeclaration | VariableDeclaration + propertyName?: Identifier; +>propertyName : Identifier +>Identifier : Identifier + + dotDotDotToken?: Node; +>dotDotDotToken : Node +>Node : Node + + name: Identifier | BindingPattern; +>name : Identifier | BindingPattern +>Identifier : Identifier +>BindingPattern : BindingPattern + + initializer?: Expression; +>initializer : Expression +>Expression : Expression + } + interface PropertyDeclaration extends Declaration, ClassElement { >PropertyDeclaration : PropertyDeclaration +>Declaration : Declaration +>ClassElement : ClassElement + name: DeclarationName; +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern + + questionToken?: Node; +>questionToken : Node +>Node : Node + + type?: TypeNode; +>type : TypeNode +>TypeNode : TypeNode + + initializer?: Expression; +>initializer : Expression +>Expression : Expression + } interface ObjectLiteralElement extends Declaration { >ObjectLiteralElement : ObjectLiteralElement >Declaration : Declaration _objectLiteralBrandBrand: any; >_objectLiteralBrandBrand : any + } + interface PropertyAssignment extends ObjectLiteralElement { +>PropertyAssignment : PropertyAssignment +>ObjectLiteralElement : ObjectLiteralElement + + _propertyAssignmentBrand: any; +>_propertyAssignmentBrand : any + + name: DeclarationName; +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern + + questionToken?: Node; +>questionToken : Node +>Node : Node + + initializer: Expression; +>initializer : Expression +>Expression : Expression } interface ShorthandPropertyAssignment extends ObjectLiteralElement { >ShorthandPropertyAssignment : ShorthandPropertyAssignment @@ -1054,24 +1102,42 @@ declare module ts { >questionToken : Node >Node : Node } - interface PropertyAssignment extends ObjectLiteralElement { ->PropertyAssignment : PropertyAssignment ->ObjectLiteralElement : ObjectLiteralElement + interface VariableLikeDeclaration extends Declaration { +>VariableLikeDeclaration : VariableLikeDeclaration +>Declaration : Declaration - _propertyAssignmentBrand: any; ->_propertyAssignmentBrand : any + propertyName?: Identifier; +>propertyName : Identifier +>Identifier : Identifier + + dotDotDotToken?: Node; +>dotDotDotToken : Node +>Node : Node name: DeclarationName; ->name : Identifier | LiteralExpression | ComputedPropertyName ->DeclarationName : Identifier | LiteralExpression | ComputedPropertyName +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern questionToken?: Node; >questionToken : Node >Node : Node - initializer: Expression; + type?: TypeNode; +>type : TypeNode +>TypeNode : TypeNode + + initializer?: Expression; >initializer : Expression >Expression : Expression + } + interface BindingPattern extends Node { +>BindingPattern : BindingPattern +>Node : Node + + elements: NodeArray; +>elements : NodeArray +>NodeArray : NodeArray +>BindingElement : BindingElement } /** * Several node kinds share function-like features such as a signature, @@ -1232,6 +1298,11 @@ declare module ts { type: TypeNode; >type : TypeNode +>TypeNode : TypeNode + } + interface StringLiteralTypeNode extends LiteralExpression, TypeNode { +>StringLiteralTypeNode : StringLiteralTypeNode +>LiteralExpression : LiteralExpression >TypeNode : TypeNode } interface Expression extends Node { @@ -1858,8 +1929,8 @@ declare module ts { >Declaration : Declaration name: DeclarationName; ->name : Identifier | LiteralExpression | ComputedPropertyName ->DeclarationName : Identifier | LiteralExpression | ComputedPropertyName +>name : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern +>DeclarationName : Identifier | LiteralExpression | ComputedPropertyName | BindingPattern initializer?: Expression; >initializer : Expression @@ -2027,12 +2098,6 @@ declare module ts { symbolCount: number; >symbolCount : number - isOpen: boolean; ->isOpen : boolean - - version: string; ->version : string - languageVersion: ScriptTarget; >languageVersion : ScriptTarget >ScriptTarget : ScriptTarget @@ -2673,11 +2738,11 @@ declare module ts { >node : FunctionLikeDeclaration >FunctionLikeDeclaration : FunctionLikeDeclaration - writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableOrParameterDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; ->writeTypeOfDeclaration : (declaration: ParameterDeclaration | VariableDeclaration | AccessorDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) => void ->declaration : ParameterDeclaration | VariableDeclaration | AccessorDeclaration + writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; +>writeTypeOfDeclaration : (declaration: VariableLikeDeclaration | AccessorDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) => void +>declaration : VariableLikeDeclaration | AccessorDeclaration >AccessorDeclaration : AccessorDeclaration ->VariableOrParameterDeclaration : ParameterDeclaration | VariableDeclaration +>VariableLikeDeclaration : VariableLikeDeclaration >enclosingDeclaration : Node >Node : Node >flags : TypeFormatFlags @@ -2724,6 +2789,12 @@ declare module ts { >isEmitBlocked : (sourceFile?: SourceFile) => boolean >sourceFile : SourceFile >SourceFile : SourceFile + + isUnknownIdentifier(location: Node, name: string): boolean; +>isUnknownIdentifier : (location: Node, name: string) => boolean +>location : Node +>Node : Node +>name : string } const enum SymbolFlags { >SymbolFlags : SymbolFlags @@ -2779,48 +2850,45 @@ declare module ts { SetAccessor = 65536, >SetAccessor : SymbolFlags - CallSignature = 131072, ->CallSignature : SymbolFlags + Signature = 131072, +>Signature : SymbolFlags - ConstructSignature = 262144, ->ConstructSignature : SymbolFlags - - IndexSignature = 524288, ->IndexSignature : SymbolFlags - - TypeParameter = 1048576, + TypeParameter = 262144, >TypeParameter : SymbolFlags - TypeAlias = 2097152, + TypeAlias = 524288, >TypeAlias : SymbolFlags - ExportValue = 4194304, + ExportValue = 1048576, >ExportValue : SymbolFlags - ExportType = 8388608, + ExportType = 2097152, >ExportType : SymbolFlags - ExportNamespace = 16777216, + ExportNamespace = 4194304, >ExportNamespace : SymbolFlags - Import = 33554432, + Import = 8388608, >Import : SymbolFlags - Instantiated = 67108864, + Instantiated = 16777216, >Instantiated : SymbolFlags - Merged = 134217728, + Merged = 33554432, >Merged : SymbolFlags - Transient = 268435456, + Transient = 67108864, >Transient : SymbolFlags - Prototype = 536870912, + Prototype = 134217728, >Prototype : SymbolFlags - UnionProperty = 1073741824, + UnionProperty = 268435456, >UnionProperty : SymbolFlags + Optional = 536870912, +>Optional : SymbolFlags + Enum = 384, >Enum : SymbolFlags @@ -2830,7 +2898,7 @@ declare module ts { Value = 107455, >Value : SymbolFlags - Type = 3152352, + Type = 793056, >Type : SymbolFlags Namespace = 1536, @@ -2842,9 +2910,6 @@ declare module ts { Accessor = 98304, >Accessor : SymbolFlags - Signature = 917504, ->Signature : SymbolFlags - FunctionScopedVariableExcludes = 107454, >FunctionScopedVariableExcludes : SymbolFlags @@ -2863,16 +2928,16 @@ declare module ts { FunctionExcludes = 106927, >FunctionExcludes : SymbolFlags - ClassExcludes = 3258879, + ClassExcludes = 899583, >ClassExcludes : SymbolFlags - InterfaceExcludes = 3152288, + InterfaceExcludes = 792992, >InterfaceExcludes : SymbolFlags - RegularEnumExcludes = 3258623, + RegularEnumExcludes = 899327, >RegularEnumExcludes : SymbolFlags - ConstEnumExcludes = 3259263, + ConstEnumExcludes = 899967, >ConstEnumExcludes : SymbolFlags ValueModuleExcludes = 106639, @@ -2890,22 +2955,22 @@ declare module ts { SetAccessorExcludes = 74687, >SetAccessorExcludes : SymbolFlags - TypeParameterExcludes = 2103776, + TypeParameterExcludes = 530912, >TypeParameterExcludes : SymbolFlags - TypeAliasExcludes = 3152352, + TypeAliasExcludes = 793056, >TypeAliasExcludes : SymbolFlags - ImportExcludes = 33554432, + ImportExcludes = 8388608, >ImportExcludes : SymbolFlags - ModuleMember = 35653619, + ModuleMember = 8914931, >ModuleMember : SymbolFlags ExportHasLocal = 944, >ExportHasLocal : SymbolFlags - HasLocals = 1041936, + HasLocals = 255504, >HasLocals : SymbolFlags HasExports = 1952, @@ -2914,13 +2979,13 @@ declare module ts { HasMembers = 6240, >HasMembers : SymbolFlags - IsContainer = 1048560, + IsContainer = 262128, >IsContainer : SymbolFlags PropertyOrAccessor = 98308, >PropertyOrAccessor : SymbolFlags - Export = 29360128, + Export = 7340032, >Export : SymbolFlags } interface Symbol { @@ -3124,6 +3189,9 @@ declare module ts { FromSignature = 65536, >FromSignature : TypeFlags + Unwidened = 131072, +>Unwidened : TypeFlags + Intrinsic = 127, >Intrinsic : TypeFlags @@ -4245,6 +4313,12 @@ declare module ts { >getNodeConstructor : (kind: SyntaxKind) => new () => Node >kind : SyntaxKind >SyntaxKind : SyntaxKind +>Node : Node + + function createNode(kind: SyntaxKind): Node; +>createNode : (kind: SyntaxKind) => Node +>kind : SyntaxKind +>SyntaxKind : SyntaxKind >Node : Node function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T; @@ -4262,14 +4336,19 @@ declare module ts { >T : T >T : T - function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen?: boolean): SourceFile; ->createSourceFile : (filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen?: boolean) => SourceFile + function createCompilerHost(options: CompilerOptions): CompilerHost; +>createCompilerHost : (options: CompilerOptions) => CompilerHost +>options : CompilerOptions +>CompilerOptions : CompilerOptions +>CompilerHost : CompilerHost + + function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; +>createSourceFile : (filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile >filename : string >sourceText : string >languageVersion : ScriptTarget >ScriptTarget : ScriptTarget ->version : string ->isOpen : boolean +>setParentNodes : boolean >SourceFile : SourceFile function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program; @@ -4452,6 +4531,12 @@ declare module ts { interface SourceFile { >SourceFile : SourceFile + isOpen: boolean; +>isOpen : boolean + + version: string; +>version : string + getScriptSnapshot(): IScriptSnapshot; >getScriptSnapshot : () => IScriptSnapshot >IScriptSnapshot : IScriptSnapshot @@ -4536,6 +4621,14 @@ declare module ts { log(s: string): void; >log : (s: string) => void +>s : string + + trace(s: string): void; +>trace : (s: string) => void +>s : string + + error(s: string): void; +>error : (s: string) => void >s : string } interface LanguageServiceHost extends Logger { @@ -5720,6 +5813,18 @@ declare module ts { throwIfCancellationRequested(): void; >throwIfCancellationRequested : () => void } + function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile; +>createLanguageServiceSourceFile : (filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean) => SourceFile +>filename : string +>scriptSnapshot : IScriptSnapshot +>IScriptSnapshot : IScriptSnapshot +>scriptTarget : ScriptTarget +>ScriptTarget : ScriptTarget +>version : string +>isOpen : boolean +>setNodeParents : boolean +>SourceFile : SourceFile + function createDocumentRegistry(): DocumentRegistry; >createDocumentRegistry : () => DocumentRegistry >DocumentRegistry : DocumentRegistry diff --git a/tests/cases/compiler/APISample_node_compile.ts b/tests/cases/compiler/APISample_node_compile.ts index b138ce2b44c..7386641f383 100644 --- a/tests/cases/compiler/APISample_node_compile.ts +++ b/tests/cases/compiler/APISample_node_compile.ts @@ -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); \ No newline at end of file diff --git a/tests/cases/compiler/APISample_standalone_compile.ts b/tests/cases/compiler/APISample_standalone_compile.ts index 049aae5523f..06149b37ad0 100644 --- a/tests/cases/compiler/APISample_standalone_compile.ts +++ b/tests/cases/compiler/APISample_standalone_compile.ts @@ -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); \ No newline at end of file