From 237225b01ac8a6df92eba312a05ad0a4f52ac3b6 Mon Sep 17 00:00:00 2001 From: steveluc Date: Thu, 26 Mar 2015 00:21:27 -0700 Subject: [PATCH 01/10] Fix bug stemming from use of tsc findConfigFile by server. Server needs its own version of this because tsc always starts from the current directory but the server must start from whatever directory contains the newly opened file. --- src/server/editorServices.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 034549ab464..e29dced0627 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -751,6 +751,26 @@ module ts.server { return info; } + // This is different from the method the compiler uses because + // the compiler can assume it will always start searching in the + // current directory (the directory in which tsc was invoked). + // The server must start searching from the directory containing + // the newly opened file. + findConfigFile(searchPath: string): string { + while (true) { + var fileName = ts.combinePaths(searchPath, "tsconfig.json"); + if (sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + } + /** * Open file whose contents is managed by the client * @param filename is absolute pathname @@ -758,7 +778,13 @@ module ts.server { openClientFile(fileName: string) { var searchPath = ts.normalizePath(getDirectoryPath(fileName)); - var configFileName = ts.findConfigFile(searchPath); + this.log("Search path: " + searchPath,"Info"); + var configFileName = this.findConfigFile(searchPath); + if (configFileName) { + this.log("Config file name: " + configFileName, "Info"); + } else { + this.log("no config file"); + } if (configFileName) { configFileName = getAbsolutePath(configFileName, searchPath); } From 184ce98bf63153c8d4cf9edc25ebd6bb6d7e8538 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 26 Mar 2015 10:51:07 -0700 Subject: [PATCH 02/10] Simplify temporary name generation logic --- src/compiler/emitter.ts | 335 +++++++++++++++------------------------- 1 file changed, 125 insertions(+), 210 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 02531593de6..0358106057a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -12,12 +12,12 @@ module ts { return isExternalModule(sourceFile) || isDeclarationFile(sourceFile); } - // flag enum used to request and track usages of few dedicated temp variables - // enum values are used to set/check bit values and thus should not have bit collisions. - const enum TempVariableKind { - auto = 0, - _i = 1, - _n = 2, + // Flags enum to track count of temp variables and a few dedicated names + const enum TempFlags { + Auto = 0x00000000, // No preferred name + CountMask = 0x0FFFFFFF, // Temp variable counter + _i = 0x10000000, // Use/preference flag for '_i' + _n = 0x20000000, // Use/preference flag for '_n' } // @internal @@ -99,11 +99,10 @@ module ts { let extendsEmitted = false; let decorateEmitted = false; - let tempCount = 0; + let tempFlags = 0; let tempVariables: Identifier[]; let tempParameters: Identifier[]; let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; - let predefinedTempsInUse = TempVariableKind.auto; let exportSpecifiers: Map; let exportEquals: ExportAssignment; let hasExportStars: boolean; @@ -168,6 +167,96 @@ module ts { emit(sourceFile); } + function isUniqueName(name: string): boolean { + return !resolver.hasGlobalName(name) && + !hasProperty(currentSourceFile.identifiers, name) && + (!generatedNameSet || !hasProperty(generatedNameSet, name)) + } + + // Return the next available name in the pattern _a ... _z, _0, _1, ... + // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + function makeTempVariableName(flags: TempFlags): string { + if (flags && !(tempFlags & flags)) { + var name = flags === TempFlags._i ? "_i" : "_n" + if (isUniqueName(name)) { + tempFlags |= flags; + return name; + } + } + while (true) { + let count = tempFlags & TempFlags.CountMask; + let ch = CharacterCodes.a + count; + let name = count < 26 ? "_" + String.fromCharCode(ch) : "_" + (count - 26); + tempFlags++; + if (ch !== CharacterCodes.i && ch !== CharacterCodes.n && isUniqueName(name)) { + return name; + } + } + } + + // Generate a name that is unique within the current file and doesn't conflict with any names + // in global scope. The name is formed by adding an '_n' suffix to the specified base name, + // where n is a positive integer. Note that names generated by makeTempVariableName and + // makeUniqueName are guaranteed to never conflict. + function makeUniqueName(baseName: string): string { + // Find the first unique 'name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { + baseName += "_"; + } + let i = 1; + while (true) { + let generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return (generatedNameSet || (generatedNameSet = {}))[generatedName] = generatedName; + } + i++; + } + } + + function assignGeneratedName(node: Node, name: string) { + (nodeToGeneratedName || (nodeToGeneratedName = []))[getNodeId(node)] = unescapeIdentifier(name); + } + + function generateNameForFunctionOrClassDeclaration(node: Declaration) { + if (!node.name) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + + function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) { + if (node.name.kind === SyntaxKind.Identifier) { + let name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + assignGeneratedName(node, isUniqueLocalName(name, node) ? name : makeUniqueName(name)); + } + } + + function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) { + let expr = getExternalModuleName(node); + let baseName = expr.kind === SyntaxKind.StringLiteral ? + escapeIdentifier(makeIdentifierFromModuleName((expr).text)) : "module"; + assignGeneratedName(node, makeUniqueName(baseName)); + } + + function generateNameForImportDeclaration(node: ImportDeclaration) { + if (node.importClause) { + generateNameForImportOrExportDeclaration(node); + } + } + + function generateNameForExportDeclaration(node: ExportDeclaration) { + if (node.moduleSpecifier) { + generateNameForImportOrExportDeclaration(node); + } + } + + function generateNameForExportAssignment(node: ExportAssignment) { + if (node.expression && node.expression.kind !== SyntaxKind.Identifier) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForNode(node: Node) { switch (node.kind) { case SyntaxKind.FunctionDeclaration: @@ -190,166 +279,6 @@ module ts { case SyntaxKind.ExportAssignment: generateNameForExportAssignment(node); break; - case SyntaxKind.SourceFile: - case SyntaxKind.ModuleBlock: - forEach((node).statements, generateNameForNode); - break; - } - } - - function isUniqueName(name: string): boolean { - return !resolver.hasGlobalName(name) && - !hasProperty(currentSourceFile.identifiers, name) && - (!generatedNameSet || !hasProperty(generatedNameSet, name)) - } - - // in cases like - // for (var x of []) { - // _i; - // } - // we should be able to detect if let _i was shadowed by some temp variable that was allocated in scope - function nameConflictsWithSomeTempVariable(name: string): boolean { - // temp variable names always start with '_' - if (name.length < 2 || name.charCodeAt(0) !== CharacterCodes._) { - return false; - } - - if (name === "_i") { - return !!(predefinedTempsInUse & TempVariableKind._i); - } - - if (name === "_n") { - return !!(predefinedTempsInUse & TempVariableKind._n); - } - - if (name.length === 2 && name.charCodeAt(1) >= CharacterCodes.a && name.charCodeAt(1) <= CharacterCodes.z) { - // handles _a .. _z - let n = name.charCodeAt(1) - CharacterCodes.a; - return n < tempCount; - } - else { - // handles _1, _2... - let n = +name.substring(1); - return !isNaN(n) && n >= 0 && n < (tempCount - 26); - } - } - - // This function generates a name using the following pattern: - // _a .. _h, _j ... _z, _0, _1, ... - // It is guaranteed that generated name will not shadow any existing user-defined names, - // however it can hide another name generated by this function higher in the scope. - // NOTE: names generated by 'makeTempVariableName' and 'makeUniqueName' will never conflict. - // see comment for 'makeTempVariableName' for more information. - function makeTempVariableName(location: Node, tempVariableKind: TempVariableKind): string { - let tempName: string; - if (tempVariableKind !== TempVariableKind.auto && !(predefinedTempsInUse & tempVariableKind)) { - tempName = tempVariableKind === TempVariableKind._i ? "_i" : "_n"; - if (!resolver.resolvesToSomeValue(location, tempName)) { - predefinedTempsInUse |= tempVariableKind; - return tempName; - } - } - - do { - // Note: we avoid generating _i and _n as those are common names we want in other places. - var char = CharacterCodes.a + tempCount; - if (char !== CharacterCodes.i && char !== CharacterCodes.n) { - if (tempCount < 26) { - tempName = "_" + String.fromCharCode(char); - } - else { - tempName = "_" + (tempCount - 26); - } - } - - tempCount++; - } - while (resolver.resolvesToSomeValue(location, tempName)); - - return tempName; - } - - // Generates a name that is unique within current file and does not collide with - // any names in global scope. - // NOTE: names generated by 'makeTempVariableName' and 'makeUniqueName' will never conflict - // because of the way how these names are generated - // - makeUniqueName builds a name by picking a base name (which should not be empty string) - // and appending suffix '_' - // - makeTempVariableName creates a name using the following pattern: - // _a .. _h, _j ... _z, _0, _1, ... - // This means that names from 'makeTempVariableName' will have only one underscore at the beginning - // and names from 'makeUniqieName' will have at least one underscore in the middle - // so they will never collide. - function makeUniqueName(baseName: string): string { - Debug.assert(!!baseName); - - // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { - baseName += "_"; - } - - let i = 1; - let generatedName: string; - while (true) { - generatedName = baseName + i; - if (isUniqueName(generatedName)) { - break; - } - i++; - } - - if (!generatedNameSet) { - generatedNameSet = {}; - } - return generatedNameSet[generatedName] = generatedName; - } - - function renameNode(node: Node, name: string): string { - var nodeId = getNodeId(node); - - if (!nodeToGeneratedName) { - nodeToGeneratedName = []; - } - - return nodeToGeneratedName[nodeId] = unescapeIdentifier(name); - } - - function generateNameForFunctionOrClassDeclaration(node: Declaration) { - if (!node.name) { - renameNode(node, makeUniqueName("default")); - } - } - - function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) { - if (node.name.kind === SyntaxKind.Identifier) { - let name = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - renameNode(node, isUniqueLocalName(name, node) ? name : makeUniqueName(name)); - } - } - - function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) { - let expr = getExternalModuleName(node); - let baseName = expr.kind === SyntaxKind.StringLiteral ? - escapeIdentifier(makeIdentifierFromModuleName((expr).text)) : "module"; - renameNode(node, makeUniqueName(baseName)); - } - - function generateNameForImportDeclaration(node: ImportDeclaration) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } - } - - function generateNameForExportDeclaration(node: ExportDeclaration) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - - function generateNameForExportAssignment(node: ExportAssignment) { - if (node.expression && node.expression.kind !== SyntaxKind.Identifier) { - renameNode(node, makeUniqueName("default")); } } @@ -726,9 +655,9 @@ module ts { } // Create a temporary variable with a unique unused name. - function createTempVariable(location: Node, tempVariableKind = TempVariableKind.auto): Identifier { + function createTempVariable(flags: TempFlags): Identifier { let result = createSynthesizedNode(SyntaxKind.Identifier); - result.text = makeTempVariableName(location, tempVariableKind); + result.text = makeTempVariableName(flags); return result; } @@ -739,8 +668,8 @@ module ts { tempVariables.push(name); } - function createAndRecordTempVariable(location: Node, tempVariableKind?: TempVariableKind): Identifier { - let temp = createTempVariable(location, tempVariableKind); + function createAndRecordTempVariable(flags: TempFlags): Identifier { + let temp = createTempVariable(flags); recordTempDeclaration(temp); return temp; @@ -982,7 +911,7 @@ module ts { } function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { - let tempVariable = createAndRecordTempVariable(node); + let tempVariable = createAndRecordTempVariable(TempFlags.Auto); write("("); emit(tempVariable); write(" = "); @@ -1178,7 +1107,7 @@ module ts { return; } - let generatedVariable = createTempVariable(node); + let generatedVariable = createTempVariable(TempFlags.Auto); generatedName = generatedVariable.text; recordTempDeclaration(generatedVariable); computedPropertyNamesToGeneratedNames[node.id] = generatedName; @@ -1425,7 +1354,7 @@ module ts { function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral: ObjectLiteralExpression, firstComputedPropertyIndex: number): ParenthesizedExpression { // For computed properties, we need to create a unique handle to the object // literal so we can modify it without risking internal assignments tainting the object. - let tempVar = createAndRecordTempVariable(originalObjectLiteral); + let tempVar = createAndRecordTempVariable(TempFlags.Auto); // Hold onto the initial non-computed properties in a new object literal, // then create the rest through property accesses on the temp variable. @@ -1790,7 +1719,7 @@ module ts { emit(node); return node; } - let temp = createAndRecordTempVariable(node); + let temp = createAndRecordTempVariable(TempFlags.Auto); write("("); emit(temp); @@ -2234,10 +2163,10 @@ module ts { // // we don't want to emit a temporary variable for the RHS, just use it directly. let rhsIsIdentifier = node.expression.kind === SyntaxKind.Identifier; - let counter = createTempVariable(node, TempVariableKind._i); - let rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node); + let counter = createTempVariable(TempFlags._i); + let rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(TempFlags.Auto); - var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, TempVariableKind._n) : undefined; + var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(TempFlags._n) : undefined; // This is the let keyword for the counter and rhsReference. The let keyword for // the LHS will be emitted inside the body. @@ -2322,7 +2251,7 @@ module ts { else { // It's an empty declaration list. This can only happen in an error case, if the user wrote // for (let of []) {} - emitNodeWithoutSourceMap(createTempVariable(node)); + emitNodeWithoutSourceMap(createTempVariable(TempFlags.Auto)); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -2581,7 +2510,7 @@ module ts { // In case the root is a synthesized node, we need to pass lowestNonSynthesizedAncestor // as the location for determining uniqueness of the variable we are about to // generate. - let identifier = createTempVariable(lowestNonSynthesizedAncestor || root); + let identifier = createTempVariable(TempFlags.Auto); if (!isDeclaration) { recordTempDeclaration(identifier); } @@ -2860,11 +2789,7 @@ module ts { ? blockScopeContainer : blockScopeContainer.parent; - var hasConflictsInEnclosingScope = - resolver.resolvesToSomeValue(parent, (node).text) || - nameConflictsWithSomeTempVariable((node).text); - - if (hasConflictsInEnclosingScope) { + if (resolver.resolvesToSomeValue(parent, (node).text)) { let variableId = resolver.getBlockScopedVariableId(node); if (!blockScopedVariableToGeneratedName) { blockScopedVariableToGeneratedName = []; @@ -2900,7 +2825,7 @@ module ts { function emitParameter(node: ParameterDeclaration) { if (languageVersion < ScriptTarget.ES6) { if (isBindingPattern(node.name)) { - let name = createTempVariable(node); + let name = createTempVariable(TempFlags.Auto); if (!tempParameters) { tempParameters = []; } @@ -2954,7 +2879,7 @@ module ts { if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) { let restIndex = node.parameters.length - 1; let restParam = node.parameters[restIndex]; - let tempName = createTempVariable(node, TempVariableKind._i).text; + let tempName = createTempVariable(TempFlags._i).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -3087,15 +3012,12 @@ module ts { } function emitSignatureAndBody(node: FunctionLikeDeclaration) { - let saveTempCount = tempCount; + let saveTempFlags = tempFlags; let saveTempVariables = tempVariables; let saveTempParameters = tempParameters; - let savePredefinedTempsInUse = predefinedTempsInUse; - - tempCount = 0; + tempFlags = 0; tempVariables = undefined; tempParameters = undefined; - predefinedTempsInUse = TempVariableKind.auto; // When targeting ES6, emit arrow function natively in ES6 if (shouldEmitAsArrowFunction(node)) { @@ -3122,8 +3044,7 @@ module ts { emitExportMemberAssignment(node); } - predefinedTempsInUse = savePredefinedTempsInUse; - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; } @@ -3410,14 +3331,12 @@ module ts { } function emitConstructor(node: ClassDeclaration, baseTypeNode: TypeReferenceNode) { - let saveTempCount = tempCount; + let saveTempFlags = tempFlags; let saveTempVariables = tempVariables; let saveTempParameters = tempParameters; - let savePredefinedTempsInUse = predefinedTempsInUse; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; tempParameters = undefined; - predefinedTempsInUse = TempVariableKind.auto; // Check if we have property assignment inside class declaration. // If there is property assignment, we need to emit constructor whether users define it or not @@ -3527,8 +3446,7 @@ module ts { emitTrailingComments(ctor); } - predefinedTempsInUse = savePredefinedTempsInUse; - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; } @@ -3695,11 +3613,11 @@ module ts { write("_super"); } write(") {"); - let saveTempCount = tempCount; + let saveTempFlags = tempFlags; let saveTempVariables = tempVariables; let saveTempParameters = tempParameters; let saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; tempParameters = undefined; computedPropertyNamesToGeneratedNames = undefined; @@ -3726,7 +3644,7 @@ module ts { }); write(";"); emitTempDeclarations(/*newLine*/ true); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; @@ -4093,17 +4011,14 @@ module ts { emitEnd(node.name); write(") "); if (node.body.kind === SyntaxKind.ModuleBlock) { - let saveTempCount = tempCount; + let saveTempFlags = tempFlags; let saveTempVariables = tempVariables; - let savePredefinedTempsInUse = predefinedTempsInUse; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; - predefinedTempsInUse = TempVariableKind.auto; emit(node.body); - predefinedTempsInUse = savePredefinedTempsInUse; - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; } else { From 82b6acaab96ecb4f3573b06a550103c7f3fd77d9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 26 Mar 2015 11:07:28 -0700 Subject: [PATCH 03/10] Accepting new baselines --- tests/baselines/reference/ES5For-of21.js | 8 ++++---- tests/baselines/reference/ES5For-of22.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/ES5For-of21.js b/tests/baselines/reference/ES5For-of21.js index 9356514ea6b..d7e4db63c3b 100644 --- a/tests/baselines/reference/ES5For-of21.js +++ b/tests/baselines/reference/ES5For-of21.js @@ -4,9 +4,9 @@ for (let v of []) { } //// [ES5For-of21.js] -for (var _i = 0, _a = []; _i < _a.length; _i++) { - var v = _a[_i]; - for (var _b = 0, _c = []; _b < _c.length; _b++) { - var _i_1 = _c[_b]; +for (var _a = 0, _b = []; _a < _b.length; _a++) { + var v = _b[_a]; + for (var _c = 0, _d = []; _c < _d.length; _c++) { + var _i = _d[_c]; } } diff --git a/tests/baselines/reference/ES5For-of22.js b/tests/baselines/reference/ES5For-of22.js index 63608f36e51..87b084d52ac 100644 --- a/tests/baselines/reference/ES5For-of22.js +++ b/tests/baselines/reference/ES5For-of22.js @@ -5,12 +5,12 @@ for (var x of [1, 2, 3]) { } //// [ES5For-of22.js] -for (var _i = 0, _a = [ +for (var _i = 0, _b = [ 1, 2, 3 -]; _i < _a.length; _i++) { - var x = _a[_i]; - var _a_1 = 0; +]; _i < _b.length; _i++) { + var x = _b[_i]; + var _a = 0; console.log(x); } From 4788581f5364a733bc3aa3e282b7eb6f6bd9702b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 26 Mar 2015 16:32:27 -0700 Subject: [PATCH 04/10] Addressing CR feedback --- src/compiler/emitter.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0358106057a..8111b7d9a0c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -92,8 +92,8 @@ module ts { let currentSourceFile: SourceFile; - let generatedNameSet: Map; - let nodeToGeneratedName: string[]; + let generatedNameSet: Map = {}; + let nodeToGeneratedName: string[] = []; let blockScopedVariableToGeneratedName: string[]; let computedPropertyNamesToGeneratedNames: string[]; @@ -170,7 +170,7 @@ module ts { function isUniqueName(name: string): boolean { return !resolver.hasGlobalName(name) && !hasProperty(currentSourceFile.identifiers, name) && - (!generatedNameSet || !hasProperty(generatedNameSet, name)) + !hasProperty(generatedNameSet, name); } // Return the next available name in the pattern _a ... _z, _0, _1, ... @@ -186,11 +186,13 @@ module ts { } while (true) { let count = tempFlags & TempFlags.CountMask; - let ch = CharacterCodes.a + count; - let name = count < 26 ? "_" + String.fromCharCode(ch) : "_" + (count - 26); tempFlags++; - if (ch !== CharacterCodes.i && ch !== CharacterCodes.n && isUniqueName(name)) { - return name; + // Skip over 'i' and 'n' + if (count !== 8 && count !== 13) { + let name = count < 26 ? "_" + String.fromCharCode(CharacterCodes.a + count) : "_" + (count - 26); + if (isUniqueName(name)) { + return name; + } } } } @@ -208,14 +210,14 @@ module ts { while (true) { let generatedName = baseName + i; if (isUniqueName(generatedName)) { - return (generatedNameSet || (generatedNameSet = {}))[generatedName] = generatedName; + return generatedNameSet[generatedName] = generatedName; } i++; } } function assignGeneratedName(node: Node, name: string) { - (nodeToGeneratedName || (nodeToGeneratedName = []))[getNodeId(node)] = unescapeIdentifier(name); + nodeToGeneratedName[getNodeId(node)] = unescapeIdentifier(name); } function generateNameForFunctionOrClassDeclaration(node: Declaration) { @@ -284,10 +286,10 @@ module ts { function getGeneratedNameForNode(node: Node) { let nodeId = getNodeId(node); - if (!nodeToGeneratedName || !nodeToGeneratedName[nodeId]) { + if (!nodeToGeneratedName[nodeId]) { generateNameForNode(node); } - return nodeToGeneratedName ? nodeToGeneratedName[nodeId] : undefined; + return nodeToGeneratedName[nodeId]; } function initializeEmitterWithSourceMaps() { From 66f0715a84375cf0d112950085b96457bdeb5ec0 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 27 Mar 2015 10:30:45 -0700 Subject: [PATCH 05/10] Allow RWC runner to use default library instead of the one in json file --- src/harness/harness.ts | 8 +++++++ src/harness/loggedIO.ts | 1 + src/harness/rwcRunner.ts | 51 +++++++++++++++++++++++++++++----------- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 90ffcef07ff..90ca94b4ab6 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1703,6 +1703,14 @@ module Harness { return (Path.getFileName(filePath) === 'lib.d.ts') || (Path.getFileName(filePath) === 'lib.core.d.ts'); } + export function getDefaultLibraryFile(): { unitName: string, content: string } { + var libFile = Harness.userSpecifiedroot + Harness.libFolder + "/" + "lib.d.ts"; + return { + unitName: libFile, + content: IO.readFile(libFile) + } + } + if (Error) (Error).stackTraceLimit = 1; } diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index d9418c0e6ae..b4c88898a51 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -15,6 +15,7 @@ interface IOLog { arguments: string[]; executingPath: string; currentDirectory: string; + useDefaultLibFile?: boolean; filesRead: { path: string; codepage: number; diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index c1c3251cf02..1578d0665ca 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -32,6 +32,7 @@ module RWC { }; var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; var currentDirectory: string; + var useDefaultLibFile: boolean; after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. @@ -43,6 +44,10 @@ module RWC { baselineOpts = undefined; baseName = undefined; currentDirectory = undefined; + // useDefaultLibFile is a flag specified in the json object to indicate whether to use built/local/lib.d.ts + // or to use lib.d.ts inside the json object. If the flag is true or undefine, use the build/local/lib.d.ts + // otherwise use the lib.d.ts from the json object. + useDefaultLibFile = undefined; }); it('can compile', () => { @@ -51,32 +56,52 @@ module RWC { var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); currentDirectory = ioLog.currentDirectory; + useDefaultLibFile = ioLog.useDefaultLibFile; + if (useDefaultLibFile === undefined) { + useDefaultLibFile = true; + } runWithIOLog(ioLog, () => { opts = ts.parseCommandLine(ioLog.arguments); assert.equal(opts.errors.length, 0); + + // To provide test coverage of output javascript file, + // we will set noEmitOnError flag to be false. + opts.options.noEmitOnError = false; }); runWithIOLog(ioLog, () => { harnessCompiler.reset(); + // Load the files ts.forEach(opts.fileNames, fileName => { inputFiles.push(getHarnessCompilerInputUnit(fileName)); }); - if (!opts.options.noLib) { - // Find the lib.d.ts file in the input file and add it to the input files list - var libFile = ts.forEach(ioLog.filesRead, fileRead=> Harness.isLibraryFile(fileRead.path) ? fileRead.path : undefined); - if (libFile) { - inputFiles.push(getHarnessCompilerInputUnit(libFile)); - } - } - + // Add files to compilation ts.forEach(ioLog.filesRead, fileRead => { + // Check if the file is already added into the set of input files. var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath); - if (!inInputList) { - // Add the file to other files - otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); + + if (!Harness.isLibraryFile(fileRead.path)) { + if (!inInputList) { + otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); + } + } + else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)){ + if (!inInputList) { + // If useDefaultLibFile is true, we will use built/local/lib.d.ts + // instead of the provided lib.d.ts from json object. + // Majority of RWC code will be using built/local/lib.d.ts instead of + // lib.d.ts inside json file. However, some RWC cases will still use + // their own version of lib.d.ts because they have customized lib.d.ts + if (useDefaultLibFile) { + inputFiles.push(Harness.getDefaultLibraryFile()); + } + else { + inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); + } + } } }); @@ -115,9 +140,7 @@ module RWC { it('has the expected declaration file content', () => { Harness.Baseline.runBaseline('has the expected declaration file content', baseName + '.d.ts', () => { - if (compilerResult.errors.length || !compilerResult.declFilesCode.length) { - return null; - } + if (!compilerResult.declFilesCode.length) { return null; } return Harness.Compiler.collateOutputs(compilerResult.declFilesCode); }, false, baselineOpts); }); From e3f93b132ae5901a0c00c170222f45c06b1b46ae Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 27 Mar 2015 13:25:39 -0700 Subject: [PATCH 06/10] Ignore projectoutput folder since this will be deleted by jake command --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c54c8018ea8..e5f3fbdabaf 100644 --- a/.gitignore +++ b/.gitignore @@ -37,11 +37,13 @@ tests/*.js tests/*.js.map tests/*.d.ts *.config + scripts/debug.bat scripts/run.bat scripts/word2md.js scripts/ior.js scripts/*.js.map +tests/baselines/local/projectOutput/ coverage/ internal/ **/.DS_Store From 328347c3278d2027d00420e59d713186f2574bab Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 27 Mar 2015 13:31:02 -0700 Subject: [PATCH 07/10] Ignore projectoutput folder since this will be deleted by jake command --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c54c8018ea8..e5f3fbdabaf 100644 --- a/.gitignore +++ b/.gitignore @@ -37,11 +37,13 @@ tests/*.js tests/*.js.map tests/*.d.ts *.config + scripts/debug.bat scripts/run.bat scripts/word2md.js scripts/ior.js scripts/*.js.map +tests/baselines/local/projectOutput/ coverage/ internal/ **/.DS_Store From 20d892a7a8cb01db4017bde9d097bdd62c950833 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 27 Mar 2015 15:44:57 -0700 Subject: [PATCH 08/10] Update LKG --- bin/lib.core.d.ts | 14 + bin/lib.core.es6.d.ts | 14 + bin/lib.d.ts | 14 + bin/lib.es6.d.ts | 14 + bin/tsc.js | 9125 ++++++++------- bin/tsserver.js | 15322 ++++++++++++++----------- bin/typescript.d.ts | 440 +- bin/typescript.js | 14460 +++++++++++++---------- bin/typescriptServices.d.ts | 440 +- bin/typescriptServices.js | 14460 +++++++++++++---------- bin/typescriptServices_internal.d.ts | 52 +- bin/typescript_internal.d.ts | 52 +- 12 files changed, 30980 insertions(+), 23427 deletions(-) diff --git a/bin/lib.core.d.ts b/bin/lib.core.d.ts index 132f5ffaccf..bc4225b0d82 100644 --- a/bin/lib.core.d.ts +++ b/bin/lib.core.d.ts @@ -1170,3 +1170,17 @@ interface ArrayConstructor { } declare var Array: ArrayConstructor; + +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void; diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts index c6f3d1d1f97..97c1c7d1b40 100644 --- a/bin/lib.core.es6.d.ts +++ b/bin/lib.core.es6.d.ts @@ -1170,6 +1170,20 @@ interface ArrayConstructor { } declare var Array: ArrayConstructor; + +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void; declare type PropertyKey = string | number | symbol; interface Symbol { diff --git a/bin/lib.d.ts b/bin/lib.d.ts index e22c7351931..15bcc31c8f7 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -1171,6 +1171,20 @@ interface ArrayConstructor { declare var Array: ArrayConstructor; +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void; + ///////////////////////////// /// IE10 ECMAScript Extensions ///////////////////////////// diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts index cf849d5c72d..114e15e6d44 100644 --- a/bin/lib.es6.d.ts +++ b/bin/lib.es6.d.ts @@ -1170,6 +1170,20 @@ interface ArrayConstructor { } declare var Array: ArrayConstructor; + +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void; declare type PropertyKey = string | number | symbol; interface Symbol { diff --git a/bin/tsc.js b/bin/tsc.js index 1d7c008595d..21e5a8ff6a3 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -136,9 +136,11 @@ var ts; } ts.sum = sum; function addRange(to, from) { - for (var _i = 0, _n = from.length; _i < _n; _i++) { - var v = from[_i]; - to.push(v); + if (to && from) { + for (var _i = 0, _n = from.length; _i < _n; _i++) { + var v = from[_i]; + to.push(v); + } } } ts.addRange = addRange; @@ -168,6 +170,35 @@ var ts; return ~low; } ts.binarySearch = binarySearch; + function reduceLeft(array, f, initial) { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + function reduceRight(array, f, initial) { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + ts.reduceRight = reduceRight; var hasOwnProperty = Object.prototype.hasOwnProperty; function hasProperty(map, key) { return hasOwnProperty.call(map, key); @@ -229,14 +260,6 @@ var ts; return hasProperty(map, key) ? map[key] : undefined; } ts.lookUp = lookUp; - function mapToArray(map) { - var result = []; - for (var id in map) { - result.push(map[id]); - } - return result; - } - ts.mapToArray = mapToArray; function copyMap(source, target) { for (var p in source) { target[p] = source[p]; @@ -1025,7 +1048,7 @@ var ts; The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: 1, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: 1, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, An_import_declaration_cannot_have_modifiers: { code: 1191, category: 1, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export_or_export_assignment: { code: 1192, category: 1, key: "External module '{0}' has no default export or export assignment." }, + External_module_0_has_no_default_export: { code: 1192, category: 1, key: "External module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: 1, key: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: 1, key: "Export declarations are not permitted in an internal module." }, Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: 1, key: "Catch clause variable name must be an identifier." }, @@ -1033,6 +1056,14 @@ var ts; Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: 1, key: "Catch clause variable cannot have an initializer." }, An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: 1, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, Unterminated_Unicode_escape_sequence: { code: 1199, category: 1, key: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: 1, key: "Line terminator not permitted before arrow." }, + A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: 1, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: 1, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: 1, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, + Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: 1, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: 1, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Decorators_are_not_valid_here: { code: 1206, category: 1, key: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: 1, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, Duplicate_identifier_0: { code: 2300, category: 1, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1, key: "Static members cannot reference class type parameters." }, @@ -1215,7 +1246,10 @@ var ts; Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: 1, key: "Cannot redeclare identifier '{0}' in catch clause" }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: 1, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: 1, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2461, category: 1, key: "Type '{0}' is not an array type or a string type." }, + Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: 1, key: "Type '{0}' is not an array type or a string type." }, + The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 2496, category: 1, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." }, + External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: 1, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: 1, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1285,6 +1319,7 @@ var ts; Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: 1, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: 1, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: 1, key: "Default export of the module has or is using private name '{0}'." }, Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: 1, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: 1, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: 1, key: "Cannot find the common subdirectory path for the input files." }, @@ -1361,73 +1396,72 @@ var ts; You_cannot_rename_this_element: { code: 8000, category: 1, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: 1, key: "You cannot rename elements that are defined in the standard TypeScript library." }, yield_expressions_are_not_currently_supported: { code: 9000, category: 1, key: "'yield' expressions are not currently supported." }, - Generators_are_not_currently_supported: { code: 9001, category: 1, key: "Generators are not currently supported." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: 1, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." } + Generators_are_not_currently_supported: { code: 9001, category: 1, key: "Generators are not currently supported." } }; })(ts || (ts = {})); var ts; (function (ts) { var textToToken = { - "any": 111, - "as": 101, - "boolean": 112, - "break": 65, - "case": 66, - "catch": 67, - "class": 68, - "continue": 70, - "const": 69, - "constructor": 113, - "debugger": 71, - "declare": 114, - "default": 72, - "delete": 73, - "do": 74, - "else": 75, - "enum": 76, - "export": 77, - "extends": 78, - "false": 79, - "finally": 80, - "for": 81, - "from": 123, - "function": 82, - "get": 115, - "if": 83, - "implements": 102, - "import": 84, - "in": 85, - "instanceof": 86, - "interface": 103, - "let": 104, - "module": 116, - "new": 87, - "null": 88, - "number": 118, - "package": 105, - "private": 106, - "protected": 107, - "public": 108, - "require": 117, - "return": 89, - "set": 119, - "static": 109, - "string": 120, - "super": 90, - "switch": 91, - "symbol": 121, - "this": 92, - "throw": 93, - "true": 94, - "try": 95, - "type": 122, - "typeof": 96, - "var": 97, - "void": 98, - "while": 99, - "with": 100, - "yield": 110, - "of": 124, + "any": 112, + "as": 102, + "boolean": 113, + "break": 66, + "case": 67, + "catch": 68, + "class": 69, + "continue": 71, + "const": 70, + "constructor": 114, + "debugger": 72, + "declare": 115, + "default": 73, + "delete": 74, + "do": 75, + "else": 76, + "enum": 77, + "export": 78, + "extends": 79, + "false": 80, + "finally": 81, + "for": 82, + "from": 124, + "function": 83, + "get": 116, + "if": 84, + "implements": 103, + "import": 85, + "in": 86, + "instanceof": 87, + "interface": 104, + "let": 105, + "module": 117, + "new": 88, + "null": 89, + "number": 119, + "package": 106, + "private": 107, + "protected": 108, + "public": 109, + "require": 118, + "return": 90, + "set": 120, + "static": 110, + "string": 121, + "super": 91, + "switch": 92, + "symbol": 122, + "this": 93, + "throw": 94, + "true": 95, + "try": 96, + "type": 123, + "typeof": 97, + "var": 98, + "void": 99, + "while": 100, + "with": 101, + "yield": 111, + "of": 125, "{": 14, "}": 15, "(": 16, @@ -1466,18 +1500,19 @@ var ts; "||": 49, "?": 50, ":": 51, - "=": 52, - "+=": 53, - "-=": 54, - "*=": 55, - "/=": 56, - "%=": 57, - "<<=": 58, - ">>=": 59, - ">>>=": 60, - "&=": 61, - "|=": 62, - "^=": 63 + "=": 53, + "+=": 54, + "-=": 55, + "*=": 56, + "/=": 57, + "%=": 58, + "<<=": 59, + ">>=": 60, + ">>>=": 61, + "&=": 62, + "|=": 63, + "^=": 64, + "@": 52 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1530,6 +1565,10 @@ var ts; return tokenStrings[t]; } ts.tokenToString = tokenToString; + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; function computeLineStarts(text) { var result = new Array(); var pos = 0; @@ -1587,13 +1626,25 @@ var ts; ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { - return ch === 32 || ch === 9 || ch === 11 || ch === 12 || - ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 || - ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279; + return ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; } ts.isWhiteSpace = isWhiteSpace; function isLineBreak(ch) { - return ch === 10 || ch === 13 || ch === 8232 || ch === 8233 || ch === 133; + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; } ts.isLineBreak = isLineBreak; function isDigit(ch) { @@ -1712,8 +1763,9 @@ var ts; var ch = text.charCodeAt(pos); switch (ch) { case 13: - if (text.charCodeAt(pos + 1) === 10) + if (text.charCodeAt(pos + 1) === 10) { pos++; + } case 10: pos++; if (trailing) { @@ -1755,8 +1807,9 @@ var ts; } } if (collecting) { - if (!result) + if (!result) { result = []; + } result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine }); } continue; @@ -2102,7 +2155,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 64; + return token = 65; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2181,7 +2234,7 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 37; case 38: @@ -2189,7 +2242,7 @@ var ts; return pos += 2, token = 48; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } return pos++, token = 43; case 40: @@ -2198,7 +2251,7 @@ var ts; return pos++, token = 17; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; + return pos += 2, token = 56; } return pos++, token = 35; case 43: @@ -2206,7 +2259,7 @@ var ts; return pos += 2, token = 38; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 53; + return pos += 2, token = 54; } return pos++, token = 33; case 44: @@ -2216,7 +2269,7 @@ var ts; return pos += 2, token = 39; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 54; + return pos += 2, token = 55; } return pos++, token = 34; case 46: @@ -2271,7 +2324,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 36; case 48: @@ -2336,7 +2389,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 58; + return pos += 3, token = 59; } return pos += 2, token = 40; } @@ -2363,7 +2416,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 32; } - return pos++, token = 52; + return pos++, token = 53; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2383,7 +2436,7 @@ var ts; return pos++, token = 19; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } return pos++, token = 45; case 123: @@ -2393,13 +2446,15 @@ var ts; return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } return pos++, token = 44; case 125: return pos++, token = 15; case 126: return pos++, token = 47; + case 64: + return pos++, token = 52; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2439,12 +2494,12 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } return pos++, token = 41; } @@ -2455,7 +2510,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 36 || token === 56) { + if (token === 36 || token === 57) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2549,8 +2604,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 64 || token > 100; }, - isReservedWord: function () { return token >= 65 && token <= 100; }, + isIdentifier: function () { return token === 65 || token > 101; }, + isReservedWord: function () { return token >= 66 && token <= 101; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2565,6 +2620,501 @@ var ts; ts.createScanner = createScanner; })(ts || (ts = {})); var ts; +(function (ts) { + ts.bindTime = 0; + function getModuleInstanceState(node) { + if (node.kind === 199 || node.kind === 200) { + return 0; + } + else if (ts.isConstEnumDeclaration(node)) { + return 2; + } + else if ((node.kind === 206 || node.kind === 205) && !(node.flags & 1)) { + return 0; + } + else if (node.kind === 203) { + var state = 0; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0: + return false; + case 2: + state = 2; + return false; + case 1: + state = 1; + return true; + } + }); + return state; + } + else if (node.kind === 202) { + return getModuleInstanceState(node.body); + } + else { + return 1; + } + } + ts.getModuleInstanceState = getModuleInstanceState; + function bindSourceFile(file) { + var start = new Date().getTime(); + bindSourceFileWorker(file); + ts.bindTime += new Date().getTime() - start; + } + ts.bindSourceFile = bindSourceFile; + function bindSourceFileWorker(file) { + var _parent; + var container; + var blockScopeContainer; + var lastContainer; + var symbolCount = 0; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + file.locals = {}; + container = file; + setBlockScopeContainer(file, false); + bind(file); + file.symbolCount = symbolCount; + } + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function setBlockScopeContainer(node, cleanLocals) { + blockScopeContainer = node; + if (cleanLocals) { + blockScopeContainer.locals = undefined; + } + } + function addDeclarationToSymbol(symbol, node, symbolKind) { + symbol.flags |= symbolKind; + if (!symbol.declarations) + symbol.declarations = []; + symbol.declarations.push(node); + if (symbolKind & 1952 && !symbol.exports) + symbol.exports = {}; + if (symbolKind & 6240 && !symbol.members) + symbol.members = {}; + node.symbol = symbol; + if (symbolKind & 107455 && !symbol.valueDeclaration) + symbol.valueDeclaration = node; + } + function getDeclarationName(node) { + if (node.name) { + if (node.kind === 202 && node.name.kind === 8) { + return '"' + node.name.text + '"'; + } + if (node.name.kind === 127) { + var nameExpression = node.name.expression; + ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); + return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); + } + return node.name.text; + } + switch (node.kind) { + case 143: + case 135: + return "__constructor"; + case 142: + case 138: + return "__call"; + case 139: + return "__new"; + case 140: + return "__index"; + case 212: + return "__export"; + case 211: + return node.isExportEquals ? "export=" : "default"; + case 197: + case 198: + return node.flags & 256 ? "default" : undefined; + } + } + function getDisplayName(node) { + return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); + } + function declareSymbol(symbols, parent, node, includes, excludes) { + ts.Debug.assert(!ts.hasDynamicName(node)); + var _name = node.flags & 256 && parent ? "default" : getDeclarationName(node); + var symbol; + if (_name !== undefined) { + symbol = ts.hasProperty(symbols, _name) ? symbols[_name] : (symbols[_name] = createSymbol(0, _name)); + if (symbol.flags & excludes) { + if (node.name) { + node.name.parent = node; + } + var message = symbol.flags & 2 + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + symbol = createSymbol(0, _name); + } + } + else { + symbol = createSymbol(0, "__missing"); + } + addDeclarationToSymbol(symbol, node, includes); + symbol.parent = parent; + if (node.kind === 198 && symbol.exports) { + var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); + if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; + } + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; + } + return symbol; + } + function declareModuleMember(node, symbolKind, symbolExcludes) { + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + if (symbolKind & 8388608) { + if (node.kind === 214 || (node.kind === 205 && hasExportModifier)) { + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + } + else { + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + } + } + else { + if (hasExportModifier || container.flags & 32768) { + var exportKind = (symbolKind & 107455 ? 1048576 : 0) | + (symbolKind & 793056 ? 2097152 : 0) | + (symbolKind & 1536 ? 4194304 : 0); + var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); + local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + node.localSymbol = local; + } + else { + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + } + } + } + function bindChildren(node, symbolKind, isBlockScopeContainer) { + if (symbolKind & 255504) { + node.locals = {}; + } + var saveParent = _parent; + var saveContainer = container; + var savedBlockScopeContainer = blockScopeContainer; + _parent = node; + if (symbolKind & 262128) { + container = node; + if (lastContainer) { + lastContainer.nextContainer = container; + } + lastContainer = container; + } + if (isBlockScopeContainer) { + setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 224); + } + ts.forEachChild(node, bind); + container = saveContainer; + _parent = saveParent; + blockScopeContainer = savedBlockScopeContainer; + } + function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { + switch (container.kind) { + case 202: + declareModuleMember(node, symbolKind, symbolExcludes); + break; + case 224: + if (ts.isExternalModule(container)) { + declareModuleMember(node, symbolKind, symbolExcludes); + break; + } + case 142: + case 143: + case 138: + case 139: + case 140: + case 134: + case 133: + case 135: + case 136: + case 137: + case 197: + case 162: + case 163: + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + break; + case 198: + if (node.flags & 128) { + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + break; + } + case 145: + case 154: + case 199: + declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); + break; + case 201: + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + break; + } + bindChildren(node, symbolKind, isBlockScopeContainer); + } + function isAmbientContext(node) { + while (node) { + if (node.flags & 2) + return true; + node = node.parent; + } + return false; + } + function hasExportDeclarations(node) { + var body = node.kind === 224 ? node : node.body; + if (body.kind === 224 || body.kind === 203) { + for (var _i = 0, _a = body.statements, _n = _a.length; _i < _n; _i++) { + var stat = _a[_i]; + if (stat.kind === 212 || stat.kind === 211) { + return true; + } + } + } + return false; + } + function setExportContextFlag(node) { + if (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 32768; + } + else { + node.flags &= ~32768; + } + } + function bindModuleDeclaration(node) { + setExportContextFlag(node); + if (node.name.kind === 8) { + bindDeclaration(node, 512, 106639, true); + } + else { + var state = getModuleInstanceState(node); + if (state === 0) { + bindDeclaration(node, 1024, 0, true); + } + else { + bindDeclaration(node, 512, 106639, true); + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } + } + } + } + function bindFunctionOrConstructorType(node) { + var symbol = createSymbol(131072, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072); + bindChildren(node, 131072, false); + var typeLiteralSymbol = createSymbol(2048, "__type"); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048); + typeLiteralSymbol.members = {}; + typeLiteralSymbol.members[node.kind === 142 ? "__call" : "__new"] = symbol; + } + function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { + var symbol = createSymbol(symbolKind, name); + addDeclarationToSymbol(symbol, node, symbolKind); + bindChildren(node, symbolKind, isBlockScopeContainer); + } + function bindCatchVariableDeclaration(node) { + bindChildren(node, 0, true); + } + function bindBlockScopedVariableDeclaration(node) { + switch (blockScopeContainer.kind) { + case 202: + declareModuleMember(node, 2, 107455); + break; + case 224: + if (ts.isExternalModule(container)) { + declareModuleMember(node, 2, 107455); + break; + } + default: + if (!blockScopeContainer.locals) { + blockScopeContainer.locals = {}; + } + declareSymbol(blockScopeContainer.locals, undefined, node, 2, 107455); + } + bindChildren(node, 2, false); + } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } + function bind(node) { + node.parent = _parent; + switch (node.kind) { + case 128: + bindDeclaration(node, 262144, 530912, false); + break; + case 129: + bindParameter(node); + break; + case 195: + case 152: + if (ts.isBindingPattern(node.name)) { + bindChildren(node, 0, false); + } + else if (ts.isBlockOrCatchScoped(node)) { + bindBlockScopedVariableDeclaration(node); + } + else { + bindDeclaration(node, 1, 107454, false); + } + break; + case 132: + case 131: + bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); + break; + case 221: + case 222: + bindPropertyOrMethodOrAccessor(node, 4, 107455, false); + break; + case 223: + bindPropertyOrMethodOrAccessor(node, 8, 107455, false); + break; + case 138: + case 139: + case 140: + bindDeclaration(node, 131072, 0, false); + break; + case 134: + case 133: + bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); + break; + case 197: + bindDeclaration(node, 16, 106927, true); + break; + case 135: + bindDeclaration(node, 16384, 0, true); + break; + case 136: + bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); + break; + case 137: + bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); + break; + case 142: + case 143: + bindFunctionOrConstructorType(node); + break; + case 145: + bindAnonymousDeclaration(node, 2048, "__type", false); + break; + case 154: + bindAnonymousDeclaration(node, 4096, "__object", false); + break; + case 162: + case 163: + bindAnonymousDeclaration(node, 16, "__function", true); + break; + case 220: + bindCatchVariableDeclaration(node); + break; + case 198: + bindDeclaration(node, 32, 899583, false); + break; + case 199: + bindDeclaration(node, 64, 792992, false); + break; + case 200: + bindDeclaration(node, 524288, 793056, false); + break; + case 201: + if (ts.isConst(node)) { + bindDeclaration(node, 128, 899967, false); + } + else { + bindDeclaration(node, 256, 899327, false); + } + break; + case 202: + bindModuleDeclaration(node); + break; + case 205: + case 208: + case 210: + case 214: + bindDeclaration(node, 8388608, 8388608, false); + break; + case 207: + if (node.name) { + bindDeclaration(node, 8388608, 8388608, false); + } + else { + bindChildren(node, 0, false); + } + break; + case 212: + if (!node.exportClause) { + declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + } + bindChildren(node, 0, false); + break; + case 211: + if (node.expression && node.expression.kind === 65) { + declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); + } + else { + declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608); + } + bindChildren(node, 0, false); + break; + case 224: + setExportContextFlag(node); + if (ts.isExternalModule(node)) { + bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); + break; + } + case 176: + bindChildren(node, 0, !ts.isFunctionLike(node.parent)); + break; + case 220: + case 183: + case 184: + case 185: + case 204: + bindChildren(node, 0, true); + break; + default: + var saveParent = _parent; + _parent = node; + ts.forEachChild(node, bind); + _parent = saveParent; + } + } + function bindParameter(node) { + if (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node), false); + } + else { + bindDeclaration(node, 1, 107455, false); + } + if (node.flags & 112 && + node.parent.kind === 135 && + node.parent.parent.kind === 198) { + var classDeclaration = node.parent.parent; + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); + } + } + function bindPropertyOrMethodOrAccessor(node, symbolKind, symbolExcludes, isBlockScopeContainer) { + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer); + } + else { + bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer); + } + } + } +})(ts || (ts = {})); +var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; @@ -2612,21 +3162,21 @@ var ts; ts.getFullWidth = getFullWidth; function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 32) !== 0; + return (node.parserContextFlags & 64) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 64)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || + if (!(node.parserContextFlags & 128)) { + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 32) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 32; + node.parserContextFlags |= 64; } - node.parserContextFlags |= 64; + node.parserContextFlags |= 128; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 221) { + while (node && node.kind !== 224) { node = node.parent; } return node; @@ -2708,15 +3258,15 @@ var ts; return current; } switch (current.kind) { - case 221: + case 224: + case 204: + case 220: case 202: - case 217: - case 200: - case 181: - case 182: case 183: + case 184: + case 185: return current; - case 174: + case 176: if (!isFunctionLike(current.parent)) { return current; } @@ -2727,9 +3277,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 193 && + declaration.kind === 195 && declaration.parent && - declaration.parent.kind === 217; + declaration.parent.kind === 220; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -2766,15 +3316,15 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 193: - case 150: - case 196: - case 197: - case 200: - case 199: - case 220: case 195: - case 160: + case 152: + case 198: + case 199: + case 202: + case 201: + case 223: + case 197: + case 162: errorNode = node.name; break; } @@ -2796,11 +3346,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 199 && isConst(node); + return node.kind === 201 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 150 || isBindingPattern(node))) { + while (node && (node.kind === 152 || isBindingPattern(node))) { node = node.parent; } return node; @@ -2808,14 +3358,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 193) { + if (node.kind === 195) { node = node.parent; } - if (node && node.kind === 194) { + if (node && node.kind === 196) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 175) { + if (node && node.kind === 177) { flags |= node.flags; } return flags; @@ -2830,12 +3380,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 177 && node.expression.kind === 8; + return node.kind === 179 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 128 || node.kind === 127) { + if (node.kind === 129 || node.kind === 128) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -2857,23 +3406,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 186: + case 188: return visitor(node); - case 202: - case 174: - case 178: - case 179: + case 204: + case 176: case 180: case 181: case 182: case 183: - case 187: - case 188: - case 214: - case 215: + case 184: + case 185: case 189: - case 191: + case 190: case 217: + case 218: + case 191: + case 193: + case 220: return ts.forEachChild(node, traverse); } } @@ -2882,14 +3431,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 150: - case 220: - case 128: - case 218: - case 130: + case 152: + case 223: case 129: - case 219: - case 193: + case 221: + case 132: + case 131: + case 222: + case 195: return true; } } @@ -2899,22 +3448,22 @@ var ts; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 133: - case 160: - case 195: - case 161: - case 132: - case 131: - case 134: case 135: + case 162: + case 197: + case 163: + case 134: + case 133: case 136: case 137: case 138: + case 139: case 140: - case 141: - case 160: - case 161: - case 195: + case 142: + case 143: + case 162: + case 163: + case 197: return true; } } @@ -2922,11 +3471,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 174 && isFunctionLike(node.parent); + return node && node.kind === 176 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 132 && node.parent.kind === 152; + return node && node.kind === 134 && node.parent.kind === 154; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -2945,28 +3494,28 @@ var ts; return undefined; } switch (node.kind) { - case 126: - if (node.parent.parent.kind === 196) { + case 127: + if (node.parent.parent.kind === 198) { return node; } node = node.parent; break; - case 161: + case 163: if (!includeArrowFunctions) { continue; } - case 195: - case 160: - case 200: - case 130: - case 129: + case 197: + case 162: + case 202: case 132: case 131: - case 133: case 134: + case 133: case 135: - case 199: - case 221: + case 136: + case 137: + case 201: + case 224: return node; } } @@ -2978,47 +3527,104 @@ var ts; if (!node) return node; switch (node.kind) { - case 126: - if (node.parent.parent.kind === 196) { + case 127: + if (node.parent.parent.kind === 198) { return node; } node = node.parent; break; - case 195: - case 160: - case 161: + case 197: + case 162: + case 163: if (!includeFunctions) { continue; } - case 130: - case 129: case 132: case 131: - case 133: case 134: + case 133: case 135: + case 136: + case 137: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 157) { + if (node.kind === 159) { return node.tag; } return node.expression; } ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 198: + return true; + case 132: + return node.parent.kind === 198; + case 129: + return node.parent.body && node.parent.parent.kind === 198; + case 136: + case 137: + case 134: + return node.body && node.parent.kind === 198; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + switch (node.kind) { + case 198: + if (node.decorators) { + return true; + } + return false; + case 132: + case 129: + if (node.decorators) { + return true; + } + return false; + case 136: + if (node.body && node.decorators) { + return true; + } + return false; + case 134: + case 137: + if (node.body && node.decorators) { + return true; + } + return false; + } + return false; + } + ts.nodeIsDecorated = nodeIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 198: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 134: + case 137: + return ts.forEach(node.parameters, nodeIsDecorated); + } + return false; + } + ts.childIsDecorated = childIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: case 9: - case 151: - case 152: case 153: case 154: case 155: @@ -3028,65 +3634,67 @@ var ts; case 159: case 160: case 161: - case 164: case 162: case 163: - case 165: case 166: + case 164: + case 165: case 167: case 168: - case 171: case 169: + case 170: + case 173: + case 171: case 10: - case 172: + case 174: return true; - case 125: - while (node.parent.kind === 125) { + case 126: + while (node.parent.kind === 126) { node = node.parent; } - return node.parent.kind === 142; - case 64: - if (node.parent.kind === 142) { + return node.parent.kind === 144; + case 65: + if (node.parent.kind === 144) { return true; } case 7: case 8: var _parent = node.parent; switch (_parent.kind) { - case 193: - case 128: - case 130: + case 195: case 129: - case 220: - case 218: - case 150: + case 132: + case 131: + case 223: + case 221: + case 152: return _parent.initializer === node; - case 177: - case 178: case 179: case 180: - case 186: - case 187: - case 188: - case 214: - case 190: - case 188: - return _parent.expression === node; case 181: + case 182: + case 188: + case 189: + case 190: + case 217: + case 192: + case 190: + return _parent.expression === node; + case 183: var forStatement = _parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 194) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 196) || forStatement.condition === node || forStatement.iterator === node; - case 182: - case 183: + case 184: + case 185: var forInStatement = _parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 194) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 196) || forInStatement.expression === node; - case 158: + case 160: return node === _parent.expression; - case 173: + case 175: return node === _parent.expression; - case 126: + case 127: return node === _parent.expression; default: if (isExpression(_parent)) { @@ -3104,7 +3712,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 203 && node.moduleReference.kind === 213; + return node.kind === 205 && node.moduleReference.kind === 216; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3113,41 +3721,41 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 203 && node.moduleReference.kind !== 213; + return node.kind === 205 && node.moduleReference.kind !== 216; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 204) { + if (node.kind === 206) { return node.moduleSpecifier; } - if (node.kind === 203) { + if (node.kind === 205) { var reference = node.moduleReference; - if (reference.kind === 213) { + if (reference.kind === 216) { return reference.expression; } } - if (node.kind === 210) { + if (node.kind === 212) { return node.moduleSpecifier; } } ts.getExternalModuleName = getExternalModuleName; function hasDotDotDotToken(node) { - return node && node.kind === 128 && node.dotDotDotToken !== undefined; + return node && node.kind === 129 && node.dotDotDotToken !== undefined; } ts.hasDotDotDotToken = hasDotDotDotToken; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 128: + case 129: return node.questionToken !== undefined; + case 134: + case 133: + return node.questionToken !== undefined; + case 222: + case 221: case 132: case 131: return node.questionToken !== undefined; - case 219: - case 218: - case 130: - case 129: - return node.questionToken !== undefined; } } return false; @@ -3170,7 +3778,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 149 || node.kind === 148); + return !!node && (node.kind === 151 || node.kind === 150); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -3185,33 +3793,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 161: - case 150: - case 196: - case 133: - case 199: - case 220: - case 212: - case 195: - case 160: - case 134: - case 205: - case 203: - case 208: + case 163: + case 152: + case 198: + case 135: + case 201: + case 223: + case 214: case 197: + case 162: + case 136: + case 207: + case 205: + case 210: + case 199: + case 134: + case 133: + case 202: + case 208: + case 129: + case 221: case 132: case 131: + case 137: + case 222: case 200: - case 206: case 128: - case 218: - case 130: - case 129: - case 135: - case 219: - case 198: - case 127: - case 193: + case 195: return true; } return false; @@ -3219,37 +3827,51 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 185: - case 184: - case 192: - case 179: - case 177: - case 176: - case 182: - case 183: - case 181: - case 178: - case 189: - case 186: - case 188: - case 93: - case 191: - case 175: - case 180: case 187: - case 209: + case 186: + case 194: + case 181: + case 179: + case 178: + case 184: + case 185: + case 183: + case 180: + case 191: + case 188: + case 190: + case 94: + case 193: + case 177: + case 182: + case 189: + case 211: return true; default: return false; } } ts.isStatement = isStatement; + function isClassElement(n) { + switch (n.kind) { + case 135: + case 132: + case 134: + case 136: + case 137: + case 140: + return true; + default: + return false; + } + } + ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 64 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 65 && name.kind !== 8 && name.kind !== 7) { return false; } var _parent = name.parent; - if (_parent.kind === 208 || _parent.kind === 212) { + if (_parent.kind === 210 || _parent.kind === 214) { if (_parent.propertyName) { return true; } @@ -3260,18 +3882,27 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + function isAliasSymbolDeclaration(node) { + return node.kind === 205 || + node.kind === 207 && !!node.name || + node.kind === 208 || + node.kind === 210 || + node.kind === 214 || + node.kind === 211 && node.expression.kind === 65; + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassBaseTypeNode(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 78); + var heritageClause = getHeritageClause(node.heritageClauses, 79); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassBaseTypeNode = getClassBaseTypeNode; function getClassImplementedTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 102); + var heritageClause = getHeritageClause(node.heritageClauses, 103); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 78); + var heritageClause = getHeritageClause(node.heritageClauses, 79); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -3340,7 +3971,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 65 <= token && token <= 124; + return 66 <= token && token <= 125; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -3349,19 +3980,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 126 && + declaration.name.kind === 127 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 153 && isESSymbolIdentifier(node.expression); + return node.kind === 155 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 64 || name.kind === 8 || name.kind === 7) { + if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 126) { + if (name.kind === 127) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -3376,19 +4007,19 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 64 && node.text === "Symbol"; + return node.kind === 65 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 108: - case 106: - case 107: case 109: - case 77: - case 114: - case 69: - case 72: + case 107: + case 108: + case 110: + case 78: + case 115: + case 70: + case 73: return true; } return false; @@ -3504,7 +4135,7 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 200 || n.kind === 221; + return isFunctionLike(n) || n.kind === 202 || n.kind === 224; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -3519,26 +4150,6 @@ var ts; return node; } ts.createSynthesizedNode = createSynthesizedNode; - function generateUniqueName(baseName, isExistingName) { - if (baseName.charCodeAt(0) !== 95) { - baseName = "_" + baseName; - if (!isExistingName(baseName)) { - return baseName; - } - } - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var _name = baseName + i; - if (!isExistingName(_name)) { - return _name; - } - i++; - } - } - ts.generateUniqueName = generateUniqueName; function createDiagnosticCollection() { var nonFileDiagnostics = []; var fileDiagnostics = {}; @@ -3639,10 +4250,265 @@ var ts; s; } ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(sourceFile, node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; } + }; + } + ts.createTextWriter = createTextWriter; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 135 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function shouldEmitToOwnFile(sourceFile, compilerOptions) { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { + return true; + } + return false; + } + return false; + } + ts.shouldEmitToOwnFile = shouldEmitToOwnFile; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 136) { + getAccessor = accessor; + } + else if (accessor.kind === 137) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 136 || member.kind === 137) + && (member.flags & 128) === (accessor.flags & 128)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 136 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 137 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + emitLeadingSpace = true; + } + }); + } + ts.emitComments = emitComments; + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + var lineCount = ts.getLineStarts(currentSourceFile).length; + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + if (pos !== comment.pos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + if (currentLineText) { + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + } + ts.writeCommentRange = writeCommentRange; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(223); + var nodeConstructors = new Array(226); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -3680,249 +4546,268 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 125: + case 126: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 127: + case 128: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 128: - case 130: case 129: - case 218: - case 219: - case 193: - case 150: - return visitNodes(cbNodes, node.modifiers) || + case 132: + case 131: + case 221: + case 222: + case 195: + case 152: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 140: - case 141: - case 136: - case 137: + case 142: + case 143: case 138: - return visitNodes(cbNodes, node.modifiers) || + case 139: + case 140: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 132: - case 131: - case 133: case 134: + case 133: case 135: - case 160: - case 195: - case 161: - return visitNodes(cbNodes, node.modifiers) || + case 136: + case 137: + case 162: + case 197: + case 163: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 139: + case 141: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 142: - return visitNode(cbNode, node.exprName); - case 143: - return visitNodes(cbNodes, node.members); case 144: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 145: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 146: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.elementType); case 147: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.elementTypes); case 148: + return visitNodes(cbNodes, node.types); case 149: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 150: case 151: return visitNodes(cbNodes, node.elements); - case 152: - return visitNodes(cbNodes, node.properties); case 153: + return visitNodes(cbNodes, node.elements); + case 154: + return visitNodes(cbNodes, node.properties); + case 155: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 154: + case 156: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 155: - case 156: + case 157: + case 158: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 157: + case 159: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 158: + case 160: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 159: - return visitNode(cbNode, node.expression); - case 162: - return visitNode(cbNode, node.expression); - case 163: + case 161: return visitNode(cbNode, node.expression); case 164: return visitNode(cbNode, node.expression); case 165: + return visitNode(cbNode, node.expression); + case 166: + return visitNode(cbNode, node.expression); + case 167: return visitNode(cbNode, node.operand); - case 170: + case 172: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 166: + case 168: return visitNode(cbNode, node.operand); - case 167: + case 169: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 168: + case 170: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 171: + case 173: return visitNode(cbNode, node.expression); - case 174: - case 201: + case 176: + case 203: return visitNodes(cbNodes, node.statements); - case 221: + case 224: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 175: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 194: - return visitNodes(cbNodes, node.declarations); case 177: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 196: + return visitNodes(cbNodes, node.declarations); + case 179: return visitNode(cbNode, node.expression); - case 178: + case 180: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 179: + case 181: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 180: + case 182: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 181: + case 183: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.iterator) || visitNode(cbNode, node.statement); - case 182: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 183: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 184: - case 185: - return visitNode(cbNode, node.label); - case 186: - return visitNode(cbNode, node.expression); - case 187: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 185: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 186: + case 187: + return visitNode(cbNode, node.label); case 188: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 202: - return visitNodes(cbNodes, node.clauses); - case 214: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 215: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 189: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 190: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 204: + return visitNodes(cbNodes, node.clauses); + case 217: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 218: + return visitNodes(cbNodes, node.statements); case 191: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 192: + return visitNode(cbNode, node.expression); + case 193: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 217: + case 220: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 196: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 197: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); + case 130: + return visitNode(cbNode, node.expression); case 198: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 199: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 200: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 199: - return visitNodes(cbNodes, node.modifiers) || + case 201: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 220: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 200: - return visitNodes(cbNodes, node.modifiers) || + case 202: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 203: - return visitNodes(cbNodes, node.modifiers) || + case 205: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 204: - return visitNodes(cbNodes, node.modifiers) || + case 206: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 205: + case 207: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 206: + case 208: return visitNode(cbNode, node.name); - case 207: - case 211: + case 209: + case 213: return visitNodes(cbNodes, node.elements); - case 210: - return visitNodes(cbNodes, node.modifiers) || + case 212: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 208: - case 212: + case 210: + case 214: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 209: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 169: + case 211: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 171: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 173: + case 175: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 126: + case 127: return visitNode(cbNode, node.expression); - case 216: + case 219: return visitNodes(cbNodes, node.types); - case 213: + case 216: return visitNode(cbNode, node.expression); + case 215: + return visitNodes(cbNodes, node.decorators); } } ts.forEachChild = forEachChild; @@ -3954,14 +4839,14 @@ var ts; ; function modifierToFlag(token) { switch (token) { - case 109: return 128; - case 108: return 16; - case 107: return 64; - case 106: return 32; - case 77: return 1; - case 114: return 2; - case 69: return 8192; - case 72: return 256; + case 110: return 128; + case 109: return 16; + case 108: return 64; + case 107: return 32; + case 78: return 1; + case 115: return 2; + case 70: return 8192; + case 73: return 256; } return 0; } @@ -3984,7 +4869,7 @@ var ts; switch (node.kind) { case 8: case 7: - case 64: + case 65: return true; } return false; @@ -4194,7 +5079,7 @@ var ts; } ts.updateSourceFile = updateSourceFile; function isEvalOrArgumentsIdentifier(node) { - return node.kind === 64 && + return node.kind === 65 && (node.text === "eval" || node.text === "arguments"); } ts.isEvalOrArgumentsIdentifier = isEvalOrArgumentsIdentifier; @@ -4272,12 +5157,13 @@ var ts; ts.createSourceFile = createSourceFile; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } + var disallowInAndDecoratorContext = 2 | 16; var parsingContext = 0; var identifiers = {}; var identifierCount = 0; var nodeCount = 0; var token; - var sourceFile = createNode(221, 0); + var sourceFile = createNode(224, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -4323,6 +5209,19 @@ var ts; function setGeneratorParameterContext(val) { setContextFlag(val, 8); } + function setDecoratorContext(val) { + setContextFlag(val, 16); + } + function doOutsideOfContext(flags, func) { + var currentContextFlags = contextFlags & flags; + if (currentContextFlags) { + setContextFlag(false, currentContextFlags); + var result = func(); + setContextFlag(true, currentContextFlags); + return result; + } + return func(); + } function allowInAnd(func) { if (contextFlags & 2) { setDisallowInContext(false); @@ -4359,6 +5258,15 @@ var ts; } return func(); } + function doInDecoratorContext(func) { + if (contextFlags & 16) { + return func(); + } + setDecoratorContext(true); + var result = func(); + setDecoratorContext(false); + return result; + } function inYieldContext() { return (contextFlags & 4) !== 0; } @@ -4371,6 +5279,9 @@ var ts; function inDisallowInContext() { return (contextFlags & 2) !== 0; } + function inDecoratorContext() { + return (contextFlags & 16) !== 0; + } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); var _length = scanner.getTextPos() - start; @@ -4431,13 +5342,13 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 64) { + if (token === 65) { return true; } - if (token === 110 && inYieldContext()) { + if (token === 111 && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 110 : token > 100; + return inStrictModeContext() ? token > 111 : token > 101; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -4508,7 +5419,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16; + node.parserContextFlags |= 32; } return node; } @@ -4530,12 +5441,12 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(64); + var node = createNode(65); node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(64, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(65, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -4558,7 +5469,7 @@ var ts; return parseIdentifierName(); } function parseComputedPropertyName() { - var node = createNode(126); + var node = createNode(127); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -4582,17 +5493,17 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); } function nextTokenCanFollowContextualModifier() { - if (token === 69) { - return nextToken() === 76; + if (token === 70) { + return nextToken() === 77; } - if (token === 77) { + if (token === 78) { nextToken(); - if (token === 72) { + if (token === 73) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 35 && token !== 14 && canFollowModifier(); } - if (token === 72) { + if (token === 73) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -4606,7 +5517,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 68 || token === 82; + return token === 69 || token === 83; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -4621,7 +5532,7 @@ var ts; case 4: return isStartOfStatement(inErrorRecovery); case 3: - return token === 66 || token === 72; + return token === 67 || token === 73; case 5: return isStartOfTypeMember(); case 6: @@ -4660,8 +5571,8 @@ var ts; return isIdentifier(); } function isNotHeritageClauseTypeName() { - if (token === 102 || - token === 78) { + if (token === 103 || + token === 79) { return lookAhead(nextTokenIsIdentifier); } return false; @@ -4682,13 +5593,13 @@ var ts; case 20: return token === 15; case 4: - return token === 15 || token === 66 || token === 72; + return token === 15 || token === 67 || token === 73; case 8: - return token === 14 || token === 78 || token === 102; + return token === 14 || token === 79 || token === 103; case 9: return isVariableDeclaratorListTerminator(); case 16: - return token === 25 || token === 16 || token === 14 || token === 78 || token === 102; + return token === 25 || token === 16 || token === 14 || token === 79 || token === 103; case 12: return token === 17 || token === 22; case 14: @@ -4781,7 +5692,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 31; + var nodeContextFlags = node.parserContextFlags & 63; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -4827,14 +5738,14 @@ var ts; function isReusableModuleElement(node) { if (node) { switch (node.kind) { - case 204: - case 203: - case 210: - case 209: - case 196: - case 197: - case 200: + case 206: + case 205: + case 212: + case 211: + case 198: case 199: + case 202: + case 201: return true; } return isReusableStatement(node); @@ -4844,12 +5755,12 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 133: - case 138: - case 132: - case 134: case 135: - case 130: + case 140: + case 134: + case 136: + case 137: + case 132: return true; } } @@ -4858,8 +5769,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 214: - case 215: + case 217: + case 218: return true; } } @@ -4868,56 +5779,56 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 195: - case 175: - case 174: - case 178: + case 197: case 177: - case 190: - case 186: - case 188: - case 185: - case 184: - case 182: - case 183: - case 181: - case 180: - case 187: case 176: - case 191: - case 189: + case 180: case 179: case 192: + case 188: + case 190: + case 187: + case 186: + case 184: + case 185: + case 183: + case 182: + case 189: + case 178: + case 193: + case 191: + case 181: + case 194: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 220; + return node.kind === 223; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 137: + case 139: + case 133: + case 140: case 131: case 138: - case 129: - case 136: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 193) { + if (node.kind !== 195) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 128) { + if (node.kind !== 129) { return false; } var parameter = node; @@ -4986,7 +5897,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(125, entity.pos); + var node = createNode(126, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -4997,13 +5908,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(64, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(169); + var template = createNode(171); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -5016,7 +5927,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(173); + var span = createNode(175); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -5050,7 +5961,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(139); + var node = createNode(141); node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 24) { node.typeArguments = parseBracketedList(17, parseType, 24, 25); @@ -5058,15 +5969,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(142); - parseExpected(96); + var node = createNode(144); + parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(127); + var node = createNode(128); node.name = parseIdentifier(); - if (parseOptional(78)) { + if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -5090,7 +6001,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token); + return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 52; } function setModifiers(node, modifiers) { if (modifiers) { @@ -5099,7 +6010,8 @@ var ts; } } function parseParameter() { - var node = createNode(128); + var node = createNode(129); + node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); @@ -5150,8 +6062,8 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 137) { - parseExpected(87); + if (kind === 139) { + parseExpected(88); } fillSignature(51, false, false, node); parseTypeMemberSemicolon(); @@ -5189,9 +6101,9 @@ var ts; nextToken(); return token === 51 || token === 23 || token === 19; } - function parseIndexSignatureDeclaration(modifiers) { - var fullStart = modifiers ? modifiers.pos : scanner.getStartPos(); - var node = createNode(138, fullStart); + function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { + var node = createNode(140, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(15, parseParameter, 18, 19); node.type = parseTypeAnnotation(); @@ -5203,7 +6115,7 @@ var ts; var _name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(131, fullStart); + var method = createNode(133, fullStart); method.name = _name; method.questionToken = questionToken; fillSignature(51, false, false, method); @@ -5211,7 +6123,7 @@ var ts; return finishNode(method); } else { - var property = createNode(129, fullStart); + var property = createNode(131, fullStart); property.name = _name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -5253,14 +6165,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(136); + return parseSignatureMember(138); case 18: return isIndexSignature() - ? parseIndexSignatureDeclaration(undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 87: + case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(137); + return parseSignatureMember(139); } case 8: case 7: @@ -5278,9 +6190,11 @@ var ts; } } function parseIndexSignatureWithModifiers() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); return isIndexSignature() - ? parseIndexSignatureDeclaration(modifiers) + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) : undefined; } function isStartOfConstructSignature() { @@ -5288,7 +6202,7 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(143); + var node = createNode(145); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -5304,12 +6218,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(145); + var node = createNode(147); node.elementTypes = parseBracketedList(18, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(147); + var node = createNode(149); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -5317,8 +6231,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 141) { - parseExpected(87); + if (kind === 143) { + parseExpected(88); } fillSignature(32, false, false, node); return finishNode(node); @@ -5329,16 +6243,16 @@ var ts; } function parseNonArrayType() { switch (token) { - case 111: - case 120: - case 118: case 112: case 121: + case 119: + case 113: + case 122: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); - case 98: + case 99: return parseTokenNode(); - case 96: + case 97: return parseTypeQuery(); case 14: return parseTypeLiteral(); @@ -5352,17 +6266,17 @@ var ts; } function isStartOfType() { switch (token) { - case 111: - case 120: - case 118: case 112: case 121: - case 98: - case 96: + case 119: + case 113: + case 122: + case 99: + case 97: case 14: case 18: case 24: - case 87: + case 88: return true; case 16: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -5378,7 +6292,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(144, type.pos); + var node = createNode(146, type.pos); node.elementType = type; type = finishNode(node); } @@ -5393,7 +6307,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(146, type.pos); + var node = createNode(148, type.pos); node.types = types; type = finishNode(node); } @@ -5413,7 +6327,7 @@ var ts; if (isIdentifier() || ts.isModifier(token)) { nextToken(); if (token === 51 || token === 23 || - token === 50 || token === 52 || + token === 50 || token === 53 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -5438,10 +6352,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(140); + return parseFunctionOrConstructorType(142); } - if (token === 87) { - return parseFunctionOrConstructorType(141); + if (token === 88) { + return parseFunctionOrConstructorType(143); } return parseUnionTypeOrHigher(); } @@ -5450,11 +6364,11 @@ var ts; } function isStartOfExpression() { switch (token) { - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: case 7: case 8: case 10: @@ -5462,22 +6376,22 @@ var ts; case 16: case 18: case 14: - case 82: - case 87: + case 83: + case 88: case 36: - case 56: + case 57: case 33: case 34: case 47: case 46: - case 73: - case 96: - case 98: + case 74: + case 97: + case 99: case 38: case 39: case 24: - case 64: - case 110: + case 65: + case 111: return true; default: if (isBinaryOperator()) { @@ -5487,23 +6401,30 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && token !== 82 && isStartOfExpression(); + return token !== 14 && token !== 83 && token !== 52 && isStartOfExpression(); } function parseExpression() { + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; while ((operatorToken = parseOptionalToken(23))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } + if (saveDecoratorContext) { + setDecoratorContext(true); + } return expr; } function parseInitializer(inParameter) { - if (token !== 52) { + if (token !== 53) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { return undefined; } } - parseExpected(52); + parseExpected(53); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -5515,7 +6436,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 64 && token === 32) { + if (expr.kind === 65 && token === 32) { return parseSimpleArrowFunctionExpression(expr); } if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { @@ -5524,7 +6445,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 110) { + if (token === 111) { if (inYieldContext()) { return true; } @@ -5545,7 +6466,7 @@ var ts; (isIdentifier() || token === 14 || token === 18); } function parseYieldExpression() { - var node = createNode(170); + var node = createNode(172); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -5559,14 +6480,14 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(161, identifier.pos); - var parameter = createNode(128, identifier.pos); + var node = createNode(163, identifier.pos); + var parameter = createNode(129, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - parseExpected(32); + node.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(); return finishNode(node); } @@ -5581,12 +6502,11 @@ var ts; if (!arrowFunction) { return undefined; } - if (parseExpected(32) || token === 14) { - arrowFunction.body = parseArrowFunctionExpressionBody(); - } - else { - arrowFunction.body = parseIdentifier(); - } + var lastToken = token; + arrowFunction.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 32 || lastToken === 14) + ? parseArrowFunctionExpressionBody() + : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { @@ -5636,7 +6556,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(161); + var node = createNode(163); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -5650,7 +6570,7 @@ var ts; if (token === 14) { return parseFunctionBlock(false, false); } - if (isStartOfStatement(true) && !isStartOfExpressionStatement() && token !== 82) { + if (isStartOfStatement(true) && !isStartOfExpressionStatement() && token !== 83) { return parseFunctionBlock(false, true); } return parseAssignmentExpressionOrHigher(); @@ -5660,10 +6580,10 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(168, leftOperand.pos); + var node = createNode(170, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; - node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); node.colonToken = parseExpectedToken(51, false, ts.Diagnostics._0_expected, ts.tokenToString(51)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); @@ -5673,7 +6593,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 85 || t === 124; + return t === 86 || t === 125; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -5682,7 +6602,7 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 85 && inDisallowInContext()) { + if (token === 86 && inDisallowInContext()) { break; } leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); @@ -5690,7 +6610,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 85) { + if (inDisallowInContext() && token === 86) { return false; } return getBinaryOperatorPrecedence() > 0; @@ -5716,8 +6636,8 @@ var ts; case 25: case 26: case 27: + case 87: case 86: - case 85: return 7; case 40: case 41: @@ -5734,33 +6654,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(167, left.pos); + var node = createNode(169, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(165); + var node = createNode(167); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(162); + var node = createNode(164); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(163); + var node = createNode(165); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(164); + var node = createNode(166); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -5774,11 +6694,11 @@ var ts; case 38: case 39: return parsePrefixUnaryExpression(); - case 73: + case 74: return parseDeleteExpression(); - case 96: + case 97: return parseTypeOfExpression(); - case 98: + case 99: return parseVoidExpression(); case 24: return parseTypeAssertion(); @@ -5790,7 +6710,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(166, expression.pos); + var node = createNode(168, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -5799,7 +6719,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 90 + var expression = token === 91 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -5813,14 +6733,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(153, expression.pos); + var node = createNode(155, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(158); + var node = createNode(160); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -5831,15 +6751,15 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(153, expression.pos); + var propertyAccess = createNode(155, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (parseOptional(18)) { - var indexedAccess = createNode(154, expression.pos); + if (!inDecoratorContext() && parseOptional(18)) { + var indexedAccess = createNode(156, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -5853,7 +6773,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(157, expression.pos); + var tagExpression = createNode(159, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -5872,7 +6792,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(155, expression.pos); + var callExpr = createNode(157, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -5880,7 +6800,7 @@ var ts; continue; } else if (token === 16) { - var _callExpr = createNode(155, expression.pos); + var _callExpr = createNode(157, expression.pos); _callExpr.expression = expression; _callExpr.arguments = parseArgumentList(); expression = finishNode(_callExpr); @@ -5939,11 +6859,11 @@ var ts; case 8: case 10: return parseLiteralNode(); - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: return parseTokenNode(); case 16: return parseParenthesizedExpression(); @@ -5951,12 +6871,12 @@ var ts; return parseArrayLiteralExpression(); case 14: return parseObjectLiteralExpression(); - case 82: + case 83: return parseFunctionExpression(); - case 87: + case 88: return parseNewExpression(); case 36: - case 56: + case 57: if (reScanSlashToken() === 9) { return parseLiteralNode(); } @@ -5967,28 +6887,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(159); + var node = createNode(161); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(171); + var node = createNode(173); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(172) : + token === 23 ? createNode(174) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { - return allowInAnd(parseArgumentOrArrayLiteralElement); + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(151); + var node = createNode(153); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; @@ -5996,19 +6916,20 @@ var ts; parseExpected(19); return finishNode(node); } - function tryParseAccessorDeclaration(fullStart, modifiers) { - if (parseContextualModifier(115)) { - return parseAccessorDeclaration(134, fullStart, modifiers); + function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { + if (parseContextualModifier(116)) { + return parseAccessorDeclaration(136, fullStart, decorators, modifiers); } - else if (parseContextualModifier(119)) { - return parseAccessorDeclaration(135, fullStart, modifiers); + else if (parseContextualModifier(120)) { + return parseAccessorDeclaration(137, fullStart, decorators, modifiers); } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, modifiers); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } @@ -6018,16 +6939,16 @@ var ts; var propertyName = parsePropertyName(); var questionToken = parseOptionalToken(50); if (asteriskToken || token === 16 || token === 24) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, propertyName, questionToken); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(219, fullStart); + var shorthandDeclaration = createNode(222, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(218, fullStart); + var propertyAssignment = createNode(221, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -6036,7 +6957,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(152); + var node = createNode(154); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; @@ -6046,20 +6967,27 @@ var ts; return finishNode(node); } function parseFunctionExpression() { - var node = createNode(160); - parseExpected(82); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var node = createNode(162); + parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); fillSignature(51, !!node.asteriskToken, false, node); node.body = parseFunctionBlock(!!node.asteriskToken, false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } return finishNode(node); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(156); - parseExpected(87); + var node = createNode(158); + parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 16) { @@ -6068,7 +6996,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(174); + var node = createNode(176); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(2, checkForStrictMode, parseStatement); parseExpected(15); @@ -6081,30 +7009,37 @@ var ts; function parseFunctionBlock(allowYield, ignoreMissingOpenBrace, diagnosticMessage) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } setYieldContext(savedYieldContext); return block; } function parseEmptyStatement() { - var node = createNode(176); + var node = createNode(178); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(178); - parseExpected(83); + var node = createNode(180); + parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(75) ? parseStatement() : undefined; + node.elseStatement = parseOptional(76) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(179); - parseExpected(74); + var node = createNode(181); + parseExpected(75); node.statement = parseStatement(); - parseExpected(99); + parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6112,8 +7047,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(180); - parseExpected(99); + var node = createNode(182); + parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6122,11 +7057,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(81); + parseExpected(82); parseExpected(16); var initializer = undefined; if (token !== 22) { - if (token === 97 || token === 104 || token === 69) { + if (token === 98 || token === 105 || token === 70) { initializer = parseVariableDeclarationList(true); } else { @@ -6134,22 +7069,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(85)) { - var forInStatement = createNode(182, pos); + if (parseOptional(86)) { + var forInStatement = createNode(184, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(124)) { - var forOfStatement = createNode(183, pos); + else if (parseOptional(125)) { + var forOfStatement = createNode(185, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(181, pos); + var forStatement = createNode(183, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -6167,7 +7102,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 185 ? 65 : 70); + parseExpected(kind === 187 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -6175,8 +7110,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(186); - parseExpected(89); + var node = createNode(188); + parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -6184,8 +7119,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(187); - parseExpected(100); + var node = createNode(189); + parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6193,30 +7128,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(214); - parseExpected(66); + var node = createNode(217); + parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); node.statements = parseList(4, false, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(215); - parseExpected(72); + var node = createNode(218); + parseExpected(73); parseExpected(51); node.statements = parseList(4, false, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 66 ? parseCaseClause() : parseDefaultClause(); + return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(188); - parseExpected(91); + var node = createNode(190); + parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(202, scanner.getStartPos()); + var caseBlock = createNode(204, scanner.getStartPos()); parseExpected(14); caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); parseExpected(15); @@ -6224,26 +7159,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(190); - parseExpected(93); + var node = createNode(192); + parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(191); - parseExpected(95); + var node = createNode(193); + parseExpected(96); node.tryBlock = parseBlock(false, false); - node.catchClause = token === 67 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 80) { - parseExpected(80); + node.catchClause = token === 68 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 81) { + parseExpected(81); node.finallyBlock = parseBlock(false, false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(217); - parseExpected(67); + var result = createNode(220); + parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -6252,22 +7187,22 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(192); - parseExpected(71); + var node = createNode(194); + parseExpected(72); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 64 && parseOptional(51)) { - var labeledStatement = createNode(189, fullStart); + if (expression.kind === 65 && parseOptional(51)) { + var labeledStatement = createNode(191, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(177, fullStart); + var expressionStatement = createNode(179, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -6275,7 +7210,7 @@ var ts; } function isStartOfStatement(inErrorRecovery) { if (ts.isModifier(token)) { - var result = lookAhead(parseVariableStatementOrFunctionDeclarationWithModifiers); + var result = lookAhead(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return true; } @@ -6284,39 +7219,39 @@ var ts; case 22: return !inErrorRecovery; case 14: - case 97: - case 104: - case 82: + case 98: + case 105: case 83: - case 74: - case 99: - case 81: - case 70: - case 65: - case 89: + case 84: + case 75: case 100: - case 91: - case 93: - case 95: + case 82: case 71: - case 67: - case 80: + case 66: + case 90: + case 101: + case 92: + case 94: + case 96: + case 72: + case 68: + case 81: return true; - case 69: + case 70: var isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; - case 103: - case 68: - case 116: - case 76: - case 122: + case 104: + case 69: + case 117: + case 77: + case 123: if (isDeclarationStart()) { return false; } - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { return false; } @@ -6326,7 +7261,7 @@ var ts; } function nextTokenIsEnumKeyword() { nextToken(); - return token === 76; + return token === 77; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -6336,46 +7271,46 @@ var ts; switch (token) { case 14: return parseBlock(false, false); - case 97: - case 69: - return parseVariableStatement(scanner.getStartPos(), undefined); - case 82: - return parseFunctionDeclaration(scanner.getStartPos(), undefined); + case 98: + case 70: + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + case 83: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 22: return parseEmptyStatement(); - case 83: + case 84: return parseIfStatement(); - case 74: + case 75: return parseDoStatement(); - case 99: - return parseWhileStatement(); - case 81: - return parseForOrForInOrForOfStatement(); - case 70: - return parseBreakOrContinueStatement(184); - case 65: - return parseBreakOrContinueStatement(185); - case 89: - return parseReturnStatement(); case 100: - return parseWithStatement(); - case 91: - return parseSwitchStatement(); - case 93: - return parseThrowStatement(); - case 95: - case 67: - case 80: - return parseTryStatement(); + return parseWhileStatement(); + case 82: + return parseForOrForInOrForOfStatement(); case 71: + return parseBreakOrContinueStatement(186); + case 66: + return parseBreakOrContinueStatement(187); + case 90: + return parseReturnStatement(); + case 101: + return parseWithStatement(); + case 92: + return parseSwitchStatement(); + case 94: + return parseThrowStatement(); + case 96: + case 68: + case 81: + return parseTryStatement(); + case 72: return parseDebuggerStatement(); - case 104: + case 105: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined); + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } default: - if (ts.isModifier(token)) { - var result = tryParse(parseVariableStatementOrFunctionDeclarationWithModifiers); + if (ts.isModifier(token) || token === 52) { + var result = tryParse(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return result; } @@ -6383,25 +7318,26 @@ var ts; return parseExpressionOrLabeledStatement(); } } - function parseVariableStatementOrFunctionDeclarationWithModifiers() { + function parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers() { var start = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 69: + case 70: var nextTokenIsEnum = lookAhead(nextTokenIsEnumKeyword); if (nextTokenIsEnum) { return undefined; } - return parseVariableStatement(start, modifiers); - case 104: + return parseVariableStatement(start, decorators, modifiers); + case 105: if (!isLetDeclaration()) { return undefined; } - return parseVariableStatement(start, modifiers); - case 97: - return parseVariableStatement(start, modifiers); - case 82: - return parseFunctionDeclaration(start, modifiers); + return parseVariableStatement(start, decorators, modifiers); + case 98: + return parseVariableStatement(start, decorators, modifiers); + case 83: + return parseFunctionDeclaration(start, decorators, modifiers); } return undefined; } @@ -6414,18 +7350,18 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(172); + return createNode(174); } - var node = createNode(150); + var node = createNode(152); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(150); + var node = createNode(152); var id = parsePropertyName(); - if (id.kind === 64 && token !== 51) { + if (id.kind === 65 && token !== 51) { node.name = id; } else { @@ -6437,14 +7373,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(148); + var node = createNode(150); parseExpected(14); node.elements = parseDelimitedList(10, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(149); + var node = createNode(151); parseExpected(18); node.elements = parseDelimitedList(11, parseArrayBindingElement); parseExpected(19); @@ -6463,7 +7399,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(193); + var node = createNode(195); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -6472,21 +7408,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(194); + var node = createNode(196); switch (token) { - case 97: + case 98: break; - case 104: + case 105: node.flags |= 4096; break; - case 69: + case 70: node.flags |= 8192; break; default: ts.Debug.fail(); } nextToken(); - if (token === 124 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 125 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -6500,33 +7436,37 @@ var ts; function canFollowContextualOfKeyword() { return nextTokenIsIdentifier() && nextToken() === 17; } - function parseVariableStatement(fullStart, modifiers) { - var node = createNode(175, fullStart); + function parseVariableStatement(fullStart, decorators, modifiers) { + var node = createNode(177, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } - function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(195, fullStart); + function parseFunctionDeclaration(fullStart, decorators, modifiers) { + var node = createNode(197, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(82); + parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); fillSignature(51, !!node.asteriskToken, false, node); node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, ts.Diagnostics.or_expected); return finishNode(node); } - function parseConstructorDeclaration(pos, modifiers) { - var node = createNode(133, pos); + function parseConstructorDeclaration(pos, decorators, modifiers) { + var node = createNode(135, pos); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(113); + parseExpected(114); fillSignature(51, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, ts.Diagnostics.or_expected); return finishNode(node); } - function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(132, fullStart); + function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { + var method = createNode(134, fullStart); + method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; @@ -6535,29 +7475,34 @@ var ts; method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); return finishNode(method); } - function parsePropertyOrMethodDeclaration(fullStart, modifiers) { + function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { + var property = createNode(132, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + property.initializer = allowInAnd(parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(35); var _name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (asteriskToken || token === 16 || token === 24) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, _name, questionToken, ts.Diagnostics.or_expected); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, _name, questionToken, ts.Diagnostics.or_expected); } else { - var property = createNode(130, fullStart); - setModifiers(property, modifiers); - property.name = _name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); + return parsePropertyDeclaration(fullStart, decorators, modifiers, _name, questionToken); } } function parseNonParameterInitializer() { return parseInitializer(false); } - function parseAccessorDeclaration(kind, fullStart, modifiers) { + function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); fillSignature(51, false, false, node); @@ -6566,6 +7511,9 @@ var ts; } function isClassMemberStart() { var idToken; + if (token === 52) { + return true; + } while (ts.isModifier(token)) { idToken = token; nextToken(); @@ -6581,14 +7529,14 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 119 || idToken === 115) { + if (!ts.isKeyword(idToken) || idToken === 120 || idToken === 116) { return true; } switch (token) { case 16: case 24: case 51: - case 52: + case 53: case 50: return true; default: @@ -6597,6 +7545,26 @@ var ts; } return false; } + function parseDecorators() { + var decorators; + while (true) { + var decoratorStart = getNodePos(); + if (!parseOptional(52)) { + break; + } + if (!decorators) { + decorators = []; + decorators.pos = scanner.getStartPos(); + } + var decorator = createNode(130, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } function parseModifiers() { var flags = 0; var modifiers; @@ -6621,30 +7589,40 @@ var ts; } function parseClassElement() { var fullStart = getNodePos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, modifiers); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } - if (token === 113) { - return parseConstructorDeclaration(fullStart, modifiers); + if (token === 114) { + return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { - return parseIndexSignatureDeclaration(modifiers); + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } if (isIdentifierOrKeyword() || token === 8 || token === 7 || token === 35 || token === 18) { - return parsePropertyOrMethodDeclaration(fullStart, modifiers); + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + if (decorators) { + var _name = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, _name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } - function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(196, fullStart); + function parseClassDeclaration(fullStart, decorators, modifiers) { + var savedStrictModeContext = inStrictModeContext(); + if (languageVersion >= 2) { + setStrictModeContext(true); + } + var node = createNode(198, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(68); + parseExpected(69); node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); @@ -6657,7 +7635,9 @@ var ts; else { node.members = createMissingList(); } - return finishNode(node); + var finishedNode = finishNode(node); + setStrictModeContext(savedStrictModeContext); + return finishedNode; } function parseHeritageClauses(isClassHeritageClause) { if (isHeritageClause()) { @@ -6671,8 +7651,8 @@ var ts; return parseList(19, false, parseHeritageClause); } function parseHeritageClause() { - if (token === 78 || token === 102) { - var node = createNode(216); + if (token === 79 || token === 103) { + var node = createNode(219); node.token = token; nextToken(); node.types = parseDelimitedList(8, parseTypeReference); @@ -6681,41 +7661,44 @@ var ts; return undefined; } function isHeritageClause() { - return token === 78 || token === 102; + return token === 79 || token === 103; } function parseClassMembers() { return parseList(6, false, parseClassElement); } - function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(197, fullStart); + function parseInterfaceDeclaration(fullStart, decorators, modifiers) { + var node = createNode(199, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(103); + parseExpected(104); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); node.members = parseObjectTypeMembers(); return finishNode(node); } - function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(198, fullStart); + function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { + var node = createNode(200, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(122); + parseExpected(123); node.name = parseIdentifier(); - parseExpected(52); + parseExpected(53); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(220, scanner.getStartPos()); + var node = createNode(223, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } - function parseEnumDeclaration(fullStart, modifiers) { - var node = createNode(199, fullStart); + function parseEnumDeclaration(fullStart, decorators, modifiers) { + var node = createNode(201, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(76); + parseExpected(77); node.name = parseIdentifier(); if (parseExpected(14)) { node.members = parseDelimitedList(7, parseEnumMember); @@ -6727,7 +7710,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(201, scanner.getStartPos()); + var node = createNode(203, scanner.getStartPos()); if (parseExpected(14)) { node.statements = parseList(1, false, parseModuleElement); parseExpected(15); @@ -6737,31 +7720,33 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, modifiers, flags) { - var node = createNode(200, fullStart); + function parseInternalModuleTail(fullStart, decorators, modifiers, flags) { + var node = createNode(202, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(20) - ? parseInternalModuleTail(getNodePos(), undefined, 1) + ? parseInternalModuleTail(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { - var node = createNode(200, fullStart); + function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { + var node = createNode(202, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart, modifiers) { - parseExpected(116); + function parseModuleDeclaration(fullStart, decorators, modifiers) { + parseExpected(117); return token === 8 - ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) - : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) + : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); } function isExternalModuleReference() { - return token === 117 && + return token === 118 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -6770,44 +7755,46 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 123; + token === 124; } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers) { - parseExpected(84); + function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { + parseExpected(85); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 123) { - var importEqualsDeclaration = createNode(203, fullStart); + if (token !== 23 && token !== 124) { + var importEqualsDeclaration = createNode(205, fullStart); + importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(52); + parseExpected(53); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(204, fullStart); + var importDeclaration = createNode(206, fullStart); + importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(123); + parseExpected(124); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(205, fullStart); + var importClause = createNode(207, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(207); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(209); } return finishNode(importClause); } @@ -6817,8 +7804,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(213); - parseExpected(117); + var node = createNode(216); + parseExpected(118); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -6832,107 +7819,116 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(206); + var namespaceImport = createNode(208); parseExpected(35); - parseExpected(101); + parseExpected(102); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 207 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(20, kind === 209 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(212); + return parseImportOrExportSpecifier(214); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(208); + return parseImportOrExportSpecifier(210); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); - var isFirstIdentifierNameNotAnIdentifier = ts.isKeyword(token) && !isIdentifier(); - var start = scanner.getTokenPos(); + var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + var checkIdentifierStart = scanner.getTokenPos(); + var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 101) { + if (token === 102) { node.propertyName = identifierName; - parseExpected(101); - if (isIdentifier()) { - node.name = parseIdentifierName(); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - } + parseExpected(102); + checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); } else { node.name = identifierName; - if (isFirstIdentifierNameNotAnIdentifier) { - parseErrorAtPosition(start, identifierName.end - start, ts.Diagnostics.Identifier_expected); - } + } + if (kind === 210 && checkIdentifierIsKeyword) { + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } - function parseExportDeclaration(fullStart, modifiers) { - var node = createNode(210, fullStart); + function parseExportDeclaration(fullStart, decorators, modifiers) { + var node = createNode(212, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(123); + parseExpected(124); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(211); - if (parseOptional(123)) { + node.exportClause = parseNamedImportsOrExports(213); + if (parseOptional(124)) { node.moduleSpecifier = parseModuleSpecifier(); } } parseSemicolon(); return finishNode(node); } - function parseExportAssignment(fullStart, modifiers) { - var node = createNode(209, fullStart); + function parseExportAssignment(fullStart, decorators, modifiers) { + var node = createNode(211, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(52)) { + if (parseOptional(53)) { node.isExportEquals = true; + node.expression = parseAssignmentExpressionOrHigher(); } else { - parseExpected(72); + parseExpected(73); + if (parseOptional(51)) { + node.type = parseType(); + } + else { + node.expression = parseAssignmentExpressionOrHigher(); + } } - node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function isLetDeclaration() { return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); } - function isDeclarationStart() { + function isDeclarationStart(followsModifier) { switch (token) { - case 97: - case 69: - case 82: + case 98: + case 70: + case 83: return true; - case 104: + case 105: return isLetDeclaration(); - case 68: - case 103: - case 76: - case 122: - return lookAhead(nextTokenIsIdentifierOrKeyword); - case 84: - return lookAhead(nextTokenCanFollowImportKeyword); - case 116: - return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 69: + case 104: case 77: + case 123: + return lookAhead(nextTokenIsIdentifierOrKeyword); + case 85: + return lookAhead(nextTokenCanFollowImportKeyword); + case 117: + return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 78: return lookAhead(nextTokenCanFollowExportKeyword); - case 114: - case 108: - case 106: - case 107: + case 115: case 109: + case 107: + case 108: + case 110: return lookAhead(nextTokenIsDeclarationStart); + case 52: + return !followsModifier; } } function isIdentifierOrKeyword() { - return token >= 64; + return token >= 65; } function nextTokenIsIdentifierOrKeyword() { nextToken(); @@ -6949,48 +7945,56 @@ var ts; } function nextTokenCanFollowExportKeyword() { nextToken(); - return token === 52 || token === 35 || - token === 14 || token === 72 || isDeclarationStart(); + return token === 53 || token === 35 || + token === 14 || token === 73 || isDeclarationStart(true); } function nextTokenIsDeclarationStart() { nextToken(); - return isDeclarationStart(); + return isDeclarationStart(true); } function nextTokenIsAsKeyword() { - return nextToken() === 101; + return nextToken() === 102; } function parseDeclaration() { var fullStart = getNodePos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (token === 77) { + if (token === 78) { nextToken(); - if (token === 72 || token === 52) { - return parseExportAssignment(fullStart, modifiers); + if (token === 73 || token === 53) { + return parseExportAssignment(fullStart, decorators, modifiers); } if (token === 35 || token === 14) { - return parseExportDeclaration(fullStart, modifiers); + return parseExportDeclaration(fullStart, decorators, modifiers); } } switch (token) { - case 97: - case 104: + case 98: + case 105: + case 70: + return parseVariableStatement(fullStart, decorators, modifiers); + case 83: + return parseFunctionDeclaration(fullStart, decorators, modifiers); case 69: - return parseVariableStatement(fullStart, modifiers); - case 82: - return parseFunctionDeclaration(fullStart, modifiers); - case 68: - return parseClassDeclaration(fullStart, modifiers); - case 103: - return parseInterfaceDeclaration(fullStart, modifiers); - case 122: - return parseTypeAliasDeclaration(fullStart, modifiers); - case 76: - return parseEnumDeclaration(fullStart, modifiers); - case 116: - return parseModuleDeclaration(fullStart, modifiers); - case 84: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers); + return parseClassDeclaration(fullStart, decorators, modifiers); + case 104: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 123: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 77: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 117: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 85: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); default: + if (decorators) { + var node = createMissingNode(215, true, ts.Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } } @@ -7065,10 +8069,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 203 && node.moduleReference.kind === 213 - || node.kind === 204 - || node.kind === 209 - || node.kind === 210 + || node.kind === 205 && node.moduleReference.kind === 216 + || node.kind === 206 + || node.kind === 211 + || node.kind === 212 ? node : undefined; }); @@ -7077,26 +8081,26 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 153: - case 154: - case 156: case 155: + case 156: + case 158: case 157: - case 151: case 159: - case 152: - case 160: - case 64: + case 153: + case 161: + case 154: + case 162: + case 65: case 9: case 7: case 8: case 10: - case 169: - case 79: - case 88: - case 92: - case 94: - case 90: + case 171: + case 80: + case 89: + case 93: + case 95: + case 91: return true; } } @@ -7104,488 +8108,29 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 52 && token <= 63; + return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; })(ts || (ts = {})); var ts; -(function (ts) { - ts.bindTime = 0; - function getModuleInstanceState(node) { - if (node.kind === 197 || node.kind === 198) { - return 0; - } - else if (ts.isConstEnumDeclaration(node)) { - return 2; - } - else if ((node.kind === 204 || node.kind === 203) && !(node.flags & 1)) { - return 0; - } - else if (node.kind === 201) { - var state = 0; - ts.forEachChild(node, function (n) { - switch (getModuleInstanceState(n)) { - case 0: - return false; - case 2: - state = 2; - return false; - case 1: - state = 1; - return true; - } - }); - return state; - } - else if (node.kind === 200) { - return getModuleInstanceState(node.body); - } - else { - return 1; - } - } - ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { - var start = new Date().getTime(); - bindSourceFileWorker(file); - ts.bindTime += new Date().getTime() - start; - } - ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { - var _parent; - var container; - var blockScopeContainer; - var lastContainer; - var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - if (!file.locals) { - file.locals = {}; - container = file; - setBlockScopeContainer(file, false); - bind(file); - file.symbolCount = symbolCount; - } - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function setBlockScopeContainer(node, cleanLocals) { - blockScopeContainer = node; - if (cleanLocals) { - blockScopeContainer.locals = undefined; - } - } - function addDeclarationToSymbol(symbol, node, symbolKind) { - symbol.flags |= symbolKind; - if (!symbol.declarations) - symbol.declarations = []; - symbol.declarations.push(node); - if (symbolKind & 1952 && !symbol.exports) - symbol.exports = {}; - if (symbolKind & 6240 && !symbol.members) - symbol.members = {}; - node.symbol = symbol; - if (symbolKind & 107455 && !symbol.valueDeclaration) - symbol.valueDeclaration = node; - } - function getDeclarationName(node) { - if (node.name) { - if (node.kind === 200 && node.name.kind === 8) { - return '"' + node.name.text + '"'; - } - if (node.name.kind === 126) { - var nameExpression = node.name.expression; - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); - } - return node.name.text; - } - switch (node.kind) { - case 141: - case 133: - return "__constructor"; - case 140: - case 136: - return "__call"; - case 137: - return "__new"; - case 138: - return "__index"; - case 210: - return "__export"; - case 209: - return "default"; - case 195: - case 196: - return node.flags & 256 ? "default" : undefined; - } - } - function getDisplayName(node) { - return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); - } - function declareSymbol(symbols, parent, node, includes, excludes) { - ts.Debug.assert(!ts.hasDynamicName(node)); - var _name = node.flags & 256 && parent ? "default" : getDeclarationName(node); - var symbol; - if (_name !== undefined) { - symbol = ts.hasProperty(symbols, _name) ? symbols[_name] : (symbols[_name] = createSymbol(0, _name)); - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } - var message = symbol.flags & 2 - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0, _name); - } - } - else { - symbol = createSymbol(0, "__missing"); - } - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - if (node.kind === 196 && symbol.exports) { - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - return symbol; - } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) - return true; - node = node.parent; - } - return false; - } - function declareModuleMember(node, symbolKind, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; - if (symbolKind & 8388608) { - if (node.kind === 212 || (node.kind === 203 && hasExportModifier)) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - } - else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - } - } - else { - if (hasExportModifier || isAmbientContext(container)) { - var exportKind = (symbolKind & 107455 ? 1048576 : 0) | - (symbolKind & 793056 ? 2097152 : 0) | - (symbolKind & 1536 ? 4194304 : 0); - var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); - local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - node.localSymbol = local; - } - else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - } - } - } - function bindChildren(node, symbolKind, isBlockScopeContainer) { - if (symbolKind & 255504) { - node.locals = {}; - } - var saveParent = _parent; - var saveContainer = container; - var savedBlockScopeContainer = blockScopeContainer; - _parent = node; - if (symbolKind & 262128) { - container = node; - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; - } - if (isBlockScopeContainer) { - setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 221); - } - ts.forEachChild(node, bind); - container = saveContainer; - _parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { - switch (container.kind) { - case 200: - declareModuleMember(node, symbolKind, symbolExcludes); - break; - case 221: - if (ts.isExternalModule(container)) { - declareModuleMember(node, symbolKind, symbolExcludes); - break; - } - case 140: - case 141: - case 136: - case 137: - case 138: - case 132: - case 131: - case 133: - case 134: - case 135: - case 195: - case 160: - case 161: - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - break; - case 196: - if (node.flags & 128) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - break; - } - case 143: - case 152: - case 197: - declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); - break; - case 199: - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - break; - } - bindChildren(node, symbolKind, isBlockScopeContainer); - } - function bindModuleDeclaration(node) { - if (node.name.kind === 8) { - bindDeclaration(node, 512, 106639, true); - } - else { - var state = getModuleInstanceState(node); - if (state === 0) { - bindDeclaration(node, 1024, 0, true); - } - else { - bindDeclaration(node, 512, 106639, true); - if (state === 2) { - node.symbol.constEnumOnlyModule = true; - } - else if (node.symbol.constEnumOnlyModule) { - node.symbol.constEnumOnlyModule = false; - } - } - } - } - function bindFunctionOrConstructorType(node) { - var symbol = createSymbol(131072, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, 131072); - bindChildren(node, 131072, false); - var typeLiteralSymbol = createSymbol(2048, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048); - typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 140 ? "__call" : "__new"] = symbol; - } - function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { - var symbol = createSymbol(symbolKind, name); - addDeclarationToSymbol(symbol, node, symbolKind); - bindChildren(node, symbolKind, isBlockScopeContainer); - } - function bindCatchVariableDeclaration(node) { - bindChildren(node, 0, true); - } - function bindBlockScopedVariableDeclaration(node) { - switch (blockScopeContainer.kind) { - case 200: - declareModuleMember(node, 2, 107455); - break; - case 221: - if (ts.isExternalModule(container)) { - declareModuleMember(node, 2, 107455); - break; - } - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; - } - declareSymbol(blockScopeContainer.locals, undefined, node, 2, 107455); - } - bindChildren(node, 2, false); - } - function getDestructuringParameterName(node) { - return "__" + ts.indexOf(node.parent.parameters, node); - } - function bind(node) { - node.parent = _parent; - switch (node.kind) { - case 127: - bindDeclaration(node, 262144, 530912, false); - break; - case 128: - bindParameter(node); - break; - case 193: - case 150: - if (ts.isBindingPattern(node.name)) { - bindChildren(node, 0, false); - } - else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); - } - else { - bindDeclaration(node, 1, 107454, false); - } - break; - case 130: - case 129: - bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); - break; - case 218: - case 219: - bindPropertyOrMethodOrAccessor(node, 4, 107455, false); - break; - case 220: - bindPropertyOrMethodOrAccessor(node, 8, 107455, false); - break; - case 136: - case 137: - case 138: - bindDeclaration(node, 131072, 0, false); - break; - case 132: - case 131: - bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); - break; - case 195: - bindDeclaration(node, 16, 106927, true); - break; - case 133: - bindDeclaration(node, 16384, 0, true); - break; - case 134: - bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); - break; - case 135: - bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); - break; - case 140: - case 141: - bindFunctionOrConstructorType(node); - break; - case 143: - bindAnonymousDeclaration(node, 2048, "__type", false); - break; - case 152: - bindAnonymousDeclaration(node, 4096, "__object", false); - break; - case 160: - case 161: - bindAnonymousDeclaration(node, 16, "__function", true); - break; - case 217: - bindCatchVariableDeclaration(node); - break; - case 196: - bindDeclaration(node, 32, 899583, false); - break; - case 197: - bindDeclaration(node, 64, 792992, false); - break; - case 198: - bindDeclaration(node, 524288, 793056, false); - break; - case 199: - if (ts.isConst(node)) { - bindDeclaration(node, 128, 899967, false); - } - else { - bindDeclaration(node, 256, 899327, false); - } - break; - case 200: - bindModuleDeclaration(node); - break; - case 203: - case 206: - case 208: - case 212: - bindDeclaration(node, 8388608, 8388608, false); - break; - case 205: - if (node.name) { - bindDeclaration(node, 8388608, 8388608, false); - } - else { - bindChildren(node, 0, false); - } - break; - case 210: - if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); - } - bindChildren(node, 0, false); - break; - case 209: - if (node.expression.kind === 64) { - declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 8388608); - } - else { - declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455); - } - bindChildren(node, 0, false); - break; - case 221: - if (ts.isExternalModule(node)) { - bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); - break; - } - case 174: - bindChildren(node, 0, !ts.isFunctionLike(node.parent)); - break; - case 217: - case 181: - case 182: - case 183: - case 202: - bindChildren(node, 0, true); - break; - default: - var saveParent = _parent; - _parent = node; - ts.forEachChild(node, bind); - _parent = saveParent; - } - } - function bindParameter(node) { - if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node), false); - } - else { - bindDeclaration(node, 1, 107455, false); - } - if (node.flags & 112 && - node.parent.kind === 133 && - node.parent.parent.kind === 196) { - var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); - } - } - function bindPropertyOrMethodOrAccessor(node, symbolKind, symbolExcludes, isBlockScopeContainer) { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer); - } - else { - bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer); - } - } - } -})(ts || (ts = {})); -var ts; (function (ts) { var nextSymbolId = 1; var nextNodeId = 1; var nextMergeId = 1; + function getNodeId(node) { + if (!node.id) + node.id = nextNodeId++; + return node.id; + } + ts.getNodeId = getNodeId; ts.checkTime = 0; + function getSymbolId(symbol) { + if (!symbol.id) { + symbol.id = nextSymbolId++; + } + return symbol.id; + } + ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -7649,7 +8194,6 @@ var ts; var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); var globals = {}; @@ -7666,10 +8210,16 @@ var ts; var globalESSymbolType; var globalIterableType; var anyArrayType; + var globalTypedPropertyDescriptorType; + var globalClassDecoratorType; + var globalParameterDecoratorType; + var globalPropertyDecoratorType; + var globalMethodDecoratorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; var emitExtends = false; + var emitDecorate = false; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -7824,20 +8374,18 @@ var ts; function getSymbolLinks(symbol) { if (symbol.flags & 67108864) return symbol; - if (!symbol.id) - symbol.id = nextSymbolId++; - return symbolLinks[symbol.id] || (symbolLinks[symbol.id] = {}); + var id = getSymbolId(symbol); + return symbolLinks[id] || (symbolLinks[id] = {}); } function getNodeLinks(node) { - if (!node.id) - node.id = nextNodeId++; - return nodeLinks[node.id] || (nodeLinks[node.id] = {}); + var nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 221); + return ts.getAncestor(node, 224); } function isGlobalSourceFile(node) { - return node.kind === 221 && !ts.isExternalModule(node); + return node.kind === 224 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -7871,6 +8419,7 @@ var ts; var lastLocation; var propertyWithInvalidInitializer; var errorLocation = location; + var grandparent; loop: while (location) { if (location.locals && !isGlobalSourceFile(location)) { if (result = getSymbol(location.locals, name, meaning)) { @@ -7878,25 +8427,25 @@ var ts; } } switch (location.kind) { - case 221: + case 224: if (!ts.isExternalModule(location)) break; - case 200: + case 202: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (!(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 212)) { + if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 214)) { break loop; } result = undefined; } break; - case 199: + case 201: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 130: - case 129: - if (location.parent.kind === 196 && !(location.flags & 128)) { + case 132: + case 131: + if (location.parent.kind === 198 && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -7905,8 +8454,8 @@ var ts; } } break; - case 196: - case 197: + case 198: + case 199: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -7915,28 +8464,28 @@ var ts; break loop; } break; - case 126: - var grandparent = location.parent.parent; - if (grandparent.kind === 196 || grandparent.kind === 197) { + case 127: + grandparent = location.parent.parent; + if (grandparent.kind === 198 || grandparent.kind === 199) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 132: - case 131: - case 133: case 134: + case 133: case 135: - case 195: - case 161: + case 136: + case 137: + case 197: + case 163: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 160: + case 162: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -7947,6 +8496,14 @@ var ts; break loop; } break; + case 130: + if (location.parent && location.parent.kind === 129) { + location = location.parent; + } + if (location.parent && ts.isClassElement(location.parent)) { + location = location.parent; + } + break; } lastLocation = location; location = location.parent; @@ -7978,14 +8535,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 193); + var variableDeclaration = ts.getAncestor(declaration, 195); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 175 || - variableDeclaration.parent.parent.kind === 181) { + if (variableDeclaration.parent.parent.kind === 177 || + variableDeclaration.parent.parent.kind === 183) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 183 || - variableDeclaration.parent.parent.kind === 182) { + else if (variableDeclaration.parent.parent.kind === 185 || + variableDeclaration.parent.parent.kind === 184) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -8005,49 +8562,94 @@ var ts; } return false; } - function isAliasSymbolDeclaration(node) { - return node.kind === 203 || - node.kind === 205 && !!node.name || - node.kind === 206 || - node.kind === 208 || - node.kind === 212 || - node.kind === 209; + function getAnyImportSyntax(node) { + if (ts.isAliasSymbolDeclaration(node)) { + if (node.kind === 205) { + return node; + } + while (node && node.kind !== 206) { + node = node.parent; + } + return node; + } } function getDeclarationOfAliasSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return isAliasSymbolDeclaration(d) ? d : undefined; }); + return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 213) { - var moduleSymbol = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node)); - var exportAssignmentSymbol = moduleSymbol && getResolvedExportAssignmentSymbol(moduleSymbol); - return exportAssignmentSymbol || moduleSymbol; + if (node.moduleReference.kind === 216) { + return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportAssignmentSymbol = getResolvedExportAssignmentSymbol(moduleSymbol); - if (!exportAssignmentSymbol) { - error(node.name, ts.Diagnostics.External_module_0_has_no_default_export_or_export_assignment, symbolToString(moduleSymbol)); + var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, ts.Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); } - return exportAssignmentSymbol; + return exportDefaultSymbol; } } function getTargetOfNamespaceImport(node) { - return resolveExternalModuleName(node, node.parent.parent.moduleSpecifier); + var moduleSpecifier = node.parent.parent.moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + function getMemberOfModuleVariable(moduleSymbol, name) { + if (moduleSymbol.flags & 3) { + var typeAnnotation = moduleSymbol.valueDeclaration.type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { + if (valueSymbol.flags & (793056 | 1536)) { + return valueSymbol; + } + var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) + result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) + result.members = typeSymbol.members; + if (valueSymbol.exports) + result.exports = valueSymbol.exports; + return result; + } + function getExportOfModule(symbol, name) { + if (symbol.flags & 1536) { + var exports = getExportsOfSymbol(symbol); + if (ts.hasProperty(exports, name)) { + return resolveSymbol(exports[name]); + } + } + } + function getPropertyOfVariable(symbol, name) { + if (symbol.flags & 3) { + var typeAnnotation = symbol.valueDeclaration.type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } } function getExternalModuleMember(node, specifier) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol) { + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { var _name = specifier.propertyName || specifier.name; if (_name.text) { - var symbol = getSymbol(getExportsOfSymbol(moduleSymbol), _name.text, 107455 | 793056 | 1536); + var symbolFromModule = getExportOfModule(targetSymbol, _name.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, _name.text); + var symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; if (!symbol) { error(_name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(_name)); - return; } - return symbol.flags & (107455 | 793056 | 1536) ? symbol : resolveAlias(symbol); + return symbol; } } } @@ -8060,31 +8662,34 @@ var ts; resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536); } function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793056 | 1536); + return node.expression && resolveEntityName(node.expression, 107455 | 793056 | 1536); } - function getTargetOfImportDeclaration(node) { + function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 203: - return getTargetOfImportEqualsDeclaration(node); case 205: + return getTargetOfImportEqualsDeclaration(node); + case 207: return getTargetOfImportClause(node); - case 206: - return getTargetOfNamespaceImport(node); case 208: + return getTargetOfNamespaceImport(node); + case 210: return getTargetOfImportSpecifier(node); - case 212: + case 214: return getTargetOfExportSpecifier(node); - case 209: + case 211: return getTargetOfExportAssignment(node); } } + function resolveSymbol(symbol) { + return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793056 | 1536)) ? resolveAlias(symbol) : symbol; + } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - var target = getTargetOfImportDeclaration(node); + var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -8109,10 +8714,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 209) { + if (node.kind === 211 && node.expression) { checkExpressionCached(node.expression); } - else if (node.kind === 212) { + else if (node.kind === 214) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -8122,17 +8727,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 203); + importDeclaration = ts.getAncestor(entityName, 205); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 64 && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 65 && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 64 || entityName.parent.kind === 125) { + if (entityName.kind === 65 || entityName.parent.kind === 126) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 203); + ts.Debug.assert(entityName.parent.kind === 205); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -8144,13 +8749,13 @@ var ts; return undefined; } var symbol; - if (name.kind === 64) { + if (name.kind === 65) { symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return undefined; } } - else if (name.kind === 125) { + else if (name.kind === 126) { var namespace = resolveEntityName(name.left, 1536); if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) { return undefined; @@ -8206,22 +8811,22 @@ var ts; } error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["default"]; + function resolveExternalModuleSymbol(moduleSymbol) { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; } - function getResolvedExportAssignmentSymbol(moduleSymbol) { - var symbol = getExportAssignmentSymbol(moduleSymbol); - if (symbol) { - if (symbol.flags & (107455 | 793056 | 1536)) { - return symbol; - } - if (symbol.flags & 8388608) { - return resolveAlias(symbol); - } + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { + var symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (1536 | 3))) { + error(moduleReferenceExpression, ts.Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; } + return symbol; + } + function getExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="]; } function getExportsOfSymbol(symbol) { - return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports; + return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { var links = getSymbolLinks(moduleSymbol); @@ -8235,20 +8840,12 @@ var ts; } } function getExportsForModule(moduleSymbol) { - if (compilerOptions.target < 2) { - var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - return { - "default": defaultSymbol - }; - } - } var result; var visitedSymbols = []; visit(moduleSymbol); return result || moduleSymbol.exports; function visit(symbol) { - if (!ts.contains(visitedSymbols, symbol)) { + if (symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol)) { visitedSymbols.push(symbol); if (symbol !== moduleSymbol) { if (!result) { @@ -8258,9 +8855,10 @@ var ts; } var exportStars = symbol.exports["__export"]; if (exportStars) { - ts.forEach(exportStars.declarations, function (node) { + for (var _i = 0, _a = exportStars.declarations, _n = _a.length; _i < _n; _i++) { + var node = _a[_i]; visit(resolveExternalModuleName(node, node.moduleSpecifier)); - }); + } } } } @@ -8296,7 +8894,7 @@ var ts; var members = node.members; for (var _i = 0, _n = members.length; _i < _n; _i++) { var member = members[_i]; - if (member.kind === 133 && ts.nodeIsPresent(member.body)) { + if (member.kind === 135 && ts.nodeIsPresent(member.body)) { return member; } } @@ -8361,17 +8959,17 @@ var ts; } } switch (_location.kind) { - case 221: + case 224: if (!ts.isExternalModule(_location)) { break; } - case 200: + case 202: if (result = callback(getSymbolOfNode(_location).exports)) { return result; } break; - case 196: - case 197: + case 198: + case 199: if (result = callback(getSymbolOfNode(_location).members)) { return result; } @@ -8486,8 +9084,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 200 && declaration.name.kind === 8) || - (declaration.kind === 221 && ts.isExternalModule(declaration)); + return (declaration.kind === 202 && declaration.name.kind === 8) || + (declaration.kind === 224 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -8497,17 +9095,18 @@ var ts; return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 203 && - !(declaration.flags & 1) && - isDeclarationVisible(declaration.parent)) { + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & 1) && + isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, declaration)) { - aliasesToMakeVisible.push(declaration); + if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); } } else { - aliasesToMakeVisible = [declaration]; + aliasesToMakeVisible = [anyImportSyntax]; } return true; } @@ -8518,11 +9117,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 142) { + if (entityName.parent.kind === 144) { meaning = 107455 | 1048576; } - else if (entityName.kind === 125 || - entityName.parent.kind === 203) { + else if (entityName.kind === 126 || + entityName.parent.kind === 205) { meaning = 1536; } else { @@ -8566,10 +9165,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 147) { + while (node.kind === 149) { node = node.parent; } - if (node.kind === 198) { + if (node.kind === 200) { return getSymbolOfNode(node); } } @@ -8723,7 +9322,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 111); + writeKeyword(writer, 112); } } else { @@ -8741,7 +9340,7 @@ var ts; var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { - return declaration.parent.kind === 221 || declaration.parent.kind === 201; + return declaration.parent.kind === 224 || declaration.parent.kind === 203; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -8751,7 +9350,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 96); + writeKeyword(writer, 97); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -8785,7 +9384,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 16); } - writeKeyword(writer, 87); + writeKeyword(writer, 88); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, typeStack); if (flags & 64) { @@ -8805,7 +9404,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures, _d = _c.length; _b < _d; _b++) { var _signature = _c[_b]; - writeKeyword(writer, 87); + writeKeyword(writer, 88); writeSpace(writer); buildSignatureDisplay(_signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); writePunctuation(writer, 22); @@ -8816,7 +9415,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 120); + writeKeyword(writer, 121); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -8829,7 +9428,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 118); + writeKeyword(writer, 119); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -8880,7 +9479,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 78); + writeKeyword(writer, 79); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } @@ -8973,12 +9572,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 200) { + if (node.kind === 202) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 221) { + else if (node.kind === 224) { return ts.isExternalModule(node) ? node : undefined; } } @@ -9021,47 +9620,56 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 193: - case 150: - case 200: - case 196: - case 197: - case 198: + case 152: + return isDeclarationVisible(node.parent.parent); case 195: + if (ts.isBindingPattern(node.name) && + !node.name.elements.length) { + return false; + } + case 202: + case 198: case 199: - case 203: + case 200: + case 197: + case 201: + case 205: var _parent = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 203 && _parent.kind !== 221 && ts.isInAmbientContext(_parent))) { - return isGlobalSourceFile(_parent) || isUsedInExportAssignment(node); + !(node.kind !== 205 && _parent.kind !== 224 && ts.isInAmbientContext(_parent))) { + return isGlobalSourceFile(_parent); } return isDeclarationVisible(_parent); - case 130: - case 129: - case 134: - case 135: case 132: case 131: + case 136: + case 137: + case 134: + case 133: if (node.flags & (32 | 64)) { return false; } - case 133: - case 137: - case 136: - case 138: - case 128: - case 201: - case 140: - case 141: - case 143: + case 135: case 139: - case 144: + case 138: + case 140: + case 129: + case 203: + case 142: + case 143: case 145: + case 141: case 146: case 147: + case 148: + case 149: return isDeclarationVisible(node.parent); - case 127: - case 221: + case 207: + case 208: + case 210: + return false; + case 128: + case 224: return true; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -9075,15 +9683,44 @@ var ts; return links.isVisible; } } + function collectLinkedAliases(node) { + var exportSymbol; + if (node.parent && node.parent.kind === 211) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === 214) { + exportSymbol = getTargetOfExportSpecifier(node.parent); + } + var result = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + function buildVisibleNodeList(declarations) { + ts.forEach(declarations, function (declaration) { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!ts.contains(result, resultNode)) { + result.push(resultNode); + } + if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { + var internalModuleReference = declaration.moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } function getRootDeclaration(node) { - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent.parent; } return node; } function getDeclarationContainer(node) { node = getRootDeclaration(node); - return node.kind === 193 ? node.parent.parent.parent : node.parent; + return node.kind === 195 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -9106,7 +9743,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 148) { + if (pattern.kind === 150) { var _name = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, _name.text) || isNumericLiteralName(_name.text) && getIndexTypeOfType(parentType, 1) || @@ -9141,10 +9778,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 182) { + if (declaration.parent.parent.kind === 184) { return anyType; } - if (declaration.parent.parent.kind === 183) { + if (declaration.parent.parent.kind === 185) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -9153,10 +9790,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 128) { + if (declaration.kind === 129) { var func = declaration.parent; - if (func.kind === 135 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 134); + if (func.kind === 137 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 136); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -9169,7 +9806,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 219) { + if (declaration.kind === 222) { return checkIdentifier(declaration.name); } return undefined; @@ -9198,7 +9835,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 172 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 174 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -9206,7 +9843,7 @@ var ts; return !elementTypes.length ? anyArrayType : hasSpreadElement ? createArrayType(getUnionType(elementTypes)) : createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 148 + return pattern.kind === 150 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -9216,7 +9853,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 218 ? getWidenedType(type) : type; + return declaration.kind !== 221 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -9224,7 +9861,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 128 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 129 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -9237,11 +9874,20 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 217) { + if (declaration.parent.kind === 220) { return links.type = anyType; } - if (declaration.kind === 209) { - return links.type = checkExpression(declaration.expression); + if (declaration.kind === 211) { + var exportAssignment = declaration; + if (exportAssignment.expression) { + return links.type = checkExpression(exportAssignment.expression); + } + else if (exportAssignment.type) { + return links.type = getTypeFromTypeNode(exportAssignment.type); + } + else { + return links.type = anyType; + } } links.type = resolvingType; var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -9265,7 +9911,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 134) { + if (accessor.kind === 136) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -9284,8 +9930,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 134); - var setter = ts.getDeclarationOfKind(symbol, 135); + var getter = ts.getDeclarationOfKind(symbol, 136); + var setter = ts.getDeclarationOfKind(symbol, 137); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -9315,7 +9961,7 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var _getter = ts.getDeclarationOfKind(symbol, 134); + var _getter = ts.getDeclarationOfKind(symbol, 136); error(_getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -9382,7 +10028,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 197 || node.kind === 196) { + if (node.kind === 199 || node.kind === 198) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -9413,7 +10059,7 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(symbol, 196); + var declaration = ts.getDeclarationOfKind(symbol, 198); var baseTypeNode = ts.getClassBaseTypeNode(declaration); if (baseTypeNode) { var baseType = getTypeFromTypeReferenceNode(baseTypeNode); @@ -9454,7 +10100,7 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 197 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 199 && ts.getInterfaceBaseTypeNodes(declaration)) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { @@ -9485,7 +10131,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 198); + var declaration = ts.getDeclarationOfKind(symbol, 200); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -9493,7 +10139,7 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var _declaration = ts.getDeclarationOfKind(symbol, 198); + var _declaration = ts.getDeclarationOfKind(symbol, 200); error(_declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; @@ -9512,7 +10158,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 127).constraint) { + if (!ts.getDeclarationOfKind(symbol, 128).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -9925,20 +10571,29 @@ var ts; }); return result; } + function symbolsToArray(symbols) { + var result = []; + for (var id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } function getExportsOfExternalModule(node) { if (!node.moduleSpecifier) { return emptyArray; } var module = resolveExternalModuleName(node, node.moduleSpecifier); - if (!module || !module.exports) { + if (!module) { return emptyArray; } - return ts.mapToArray(getExportsOfModule(module)); + return symbolsToArray(getExportsOfModule(module)); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 133 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 135 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -9967,8 +10622,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 134 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 135); + if (declaration.kind === 136 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 137); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -9986,19 +10641,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 140: - case 141: - case 195: - case 132: - case 131: + case 142: + case 143: + case 197: + case 134: case 133: + case 135: + case 138: + case 139: + case 140: case 136: case 137: - case 138: - case 134: - case 135: - case 160: - case 161: + case 162: + case 163: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -10068,7 +10723,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 133 || signature.declaration.kind === 137; + var isConstructor = signature.declaration.kind === 135 || signature.declaration.kind === 139; var type = createObjectType(32768 | 65536); type.members = emptySymbols; type.properties = emptyArray; @@ -10082,7 +10737,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 118 : 120; + var syntaxKind = kind === 1 ? 119 : 121; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -10112,7 +10767,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 127).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 128).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -10162,13 +10817,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 127; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 128; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 139 && n.typeName.kind === 64) { + if (n.kind === 141 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -10233,9 +10888,9 @@ var ts; for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 196: - case 197: + case 198: case 199: + case 201: return declaration; } } @@ -10412,38 +11067,38 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 111: - return anyType; - case 120: - return stringType; - case 118: - return numberType; case 112: - return booleanType; + return anyType; case 121: + return stringType; + case 119: + return numberType; + case 113: + return booleanType; + case 122: return esSymbolType; - case 98: + case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 139: - return getTypeFromTypeReferenceNode(node); - case 142: - return getTypeFromTypeQueryNode(node); - case 144: - return getTypeFromArrayTypeNode(node); - case 145: - return getTypeFromTupleTypeNode(node); - case 146: - return getTypeFromUnionTypeNode(node); - case 147: - return getTypeFromTypeNode(node.type); - case 140: case 141: + return getTypeFromTypeReferenceNode(node); + case 144: + return getTypeFromTypeQueryNode(node); + case 146: + return getTypeFromArrayTypeNode(node); + case 147: + return getTypeFromTupleTypeNode(node); + case 148: + return getTypeFromUnionTypeNode(node); + case 149: + return getTypeFromTypeNode(node.type); + case 142: case 143: + case 145: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 64: - case 125: + case 65: + case 126: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -10506,6 +11161,7 @@ var ts; return function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; return getInferredType(context, i); } } @@ -10593,27 +11249,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 160: - case 161: + case 162: + case 163: return isContextSensitiveFunctionLikeDeclaration(node); - case 152: + case 154: return ts.forEach(node.properties, isContextSensitive); - case 151: + case 153: return ts.forEach(node.elements, isContextSensitive); - case 168: + case 170: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 167: + case 169: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 218: + case 221: return isContextSensitive(node.initializer); - case 132: - case 131: + case 134: + case 133: return isContextSensitiveFunctionLikeDeclaration(node); - case 159: + case 161: return isContextSensitive(node.expression); } return false; @@ -10669,6 +11325,7 @@ var ts; var expandingFlags; var depth = 0; var overflow = false; + var elaborateErrors = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); if (overflow) { @@ -10677,7 +11334,8 @@ var ts; else if (errorInfo) { if (errorInfo.next === undefined) { errorInfo = undefined; - isRelatedTo(source, target, errorNode !== undefined, headMessage, true); + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); } if (containingMessageChain) { errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); @@ -10688,8 +11346,7 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } - function isRelatedTo(source, target, reportErrors, headMessage, elaborateErrors) { - if (elaborateErrors === void 0) { elaborateErrors = false; } + function isRelatedTo(source, target, reportErrors, headMessage) { var _result; if (source === target) return -1; @@ -10759,7 +11416,7 @@ var ts; var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); if (sourceOrApparentType.flags & 48128 && target.flags & 48128 && - (_result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors, elaborateErrors))) { + (_result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { errorInfo = saveErrorInfo; return _result; } @@ -10848,8 +11505,7 @@ var ts; return 0; } } - function objectTypeRelatedTo(source, target, reportErrors, elaborateErrors) { - if (elaborateErrors === void 0) { elaborateErrors = false; } + function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0; } @@ -11283,6 +11939,7 @@ var ts; downfallType = types[j]; } } + ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); if (score > bestSupertypeScore) { bestSupertype = types[i]; bestSupertypeDownfallType = downfallType; @@ -11381,22 +12038,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 130: - case 129: + case 132: + case 131: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 128: + case 129: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 195: - case 132: - case 131: + case 197: case 134: - case 135: - case 160: - case 161: + case 133: + case 136: + case 137: + case 162: + case 163: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -11445,12 +12102,11 @@ var ts; var inferences = []; for (var _i = 0, _n = typeParameters.length; _i < _n; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined }); + inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); } return { typeParameters: typeParameters, inferUnionTypes: inferUnionTypes, - inferenceCount: 0, inferences: inferences, inferredTypes: new Array(typeParameters.length) }; @@ -11492,12 +12148,15 @@ var ts; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { var inferences = context.inferences[i]; - var candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) - candidates.push(source); - break; + if (!inferences.isFixed) { + var candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!ts.contains(candidates, source)) { + candidates.push(source); + } + } + return; } } } @@ -11595,19 +12254,25 @@ var ts; } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; + var inferenceSucceeded; if (!inferredType) { var inferences = getInferenceCandidates(context, index); if (inferences.length) { var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType; + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; } else { inferredType = emptyObjectType; + inferenceSucceeded = true; } - if (inferredType !== inferenceFailureType) { + if (inferenceSucceeded) { var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + context.failedTypeParameterIndex = index; + } context.inferredTypes[index] = inferredType; } return inferredType; @@ -11631,10 +12296,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 142: + case 144: return true; - case 64: - case 125: + case 65: + case 126: node = node.parent; continue; default: @@ -11674,12 +12339,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 52 && node.operatorToken.kind <= 63) { + if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 159) { + while (n.kind === 161) { n = n.expression; } - if (n.kind === 64 && getResolvedSymbol(n) === symbol) { + if (n.kind === 65 && getResolvedSymbol(n) === symbol) { return true; } } @@ -11693,46 +12358,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 167: + case 169: return isAssignedInBinaryExpression(node); - case 193: - case 150: - return isAssignedInVariableDeclaration(node); - case 148: - case 149: - case 151: + case 195: case 152: + return isAssignedInVariableDeclaration(node); + case 150: + case 151: case 153: case 154: case 155: case 156: + case 157: case 158: - case 159: - case 165: - case 162: - case 163: + case 160: + case 161: + case 167: case 164: + case 165: case 166: case 168: - case 171: - case 174: - case 175: + case 170: + case 173: + case 176: case 177: - case 178: case 179: case 180: case 181: case 182: case 183: - case 186: - case 187: + case 184: + case 185: case 188: - case 214: - case 215: case 189: case 190: - case 191: case 217: + case 218: + case 191: + case 192: + case 193: + case 220: return ts.forEachChild(node, isAssignedIn); } return false; @@ -11768,17 +12433,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 178: + case 180: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 168: + case 170: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 167: + case 169: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -11788,14 +12453,14 @@ var ts; } } break; - case 221: - case 200: - case 195: - case 132: - case 131: + case 224: + case 202: + case 197: case 134: - case 135: case 133: + case 136: + case 137: + case 135: break loop; } if (narrowedType !== type) { @@ -11808,12 +12473,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 163 || expr.right.kind !== 8) { + if (expr.left.kind !== 165 || expr.right.kind !== 8) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 64 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 65 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -11859,7 +12524,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (type.flags & 1 || !assumeTrue || expr.left.kind !== 64 || getResolvedSymbol(expr.left) !== symbol) { + if (type.flags & 1 || !assumeTrue || expr.left.kind !== 65 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -11881,9 +12546,9 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 159: + case 161: return narrowType(type, expr.expression, assumeTrue); - case 167: + case 169: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -11894,11 +12559,11 @@ var ts; else if (operator === 49) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 86) { + else if (operator === 87) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 165: + case 167: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -11909,7 +12574,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 161) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 163) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -11933,15 +12598,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 217) { + symbol.valueDeclaration.parent.kind === 220) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 194) { + while (container.kind !== 196) { container = container.parent; } container = container.parent; - if (container.kind === 175) { + if (container.kind === 177) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -11958,9 +12623,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 196 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 198 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 130 || container.kind === 133) { + if (container.kind === 132 || container.kind === 135) { getNodeLinks(classNode).flags |= 4; } else { @@ -11970,36 +12635,36 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 161) { + if (container.kind === 163) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 200: + case 202: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 199: + case 201: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 133: + case 135: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 130: - case 129: + case 132: + case 131: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 126: + case 127: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 196 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 198 ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -12008,15 +12673,15 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 128) { + if (n.kind === 129) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 155 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 196); + var isCallExpression = node.parent.kind === 157 && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 198); var baseClass; if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -12031,31 +12696,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 133; + canUseSuperExpression = container.kind === 135; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 161) { + while (container && container.kind === 163) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 196) { + if (container && container.parent && container.parent.kind === 198) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 132 || - container.kind === 131 || - container.kind === 134 || - container.kind === 135; + container.kind === 134 || + container.kind === 133 || + container.kind === 136 || + container.kind === 137; } else { canUseSuperExpression = - container.kind === 132 || + container.kind === 134 || + container.kind === 133 || + container.kind === 136 || + container.kind === 137 || + container.kind === 132 || container.kind === 131 || - container.kind === 134 || - container.kind === 135 || - container.kind === 130 || - container.kind === 129 || - container.kind === 133; + container.kind === 135; } } } @@ -12069,7 +12734,7 @@ var ts; getNodeLinks(node).flags |= 16; returnType = baseClass; } - if (container.kind === 133 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 135 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -12079,7 +12744,7 @@ var ts; return returnType; } } - if (container.kind === 126) { + if (container.kind === 127) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -12117,7 +12782,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 128) { + if (declaration.kind === 129) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -12132,7 +12797,7 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 133 || func.kind === 134 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 135))) { + if (func.type || func.kind === 135 || func.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 137))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } var signature = getContextualSignatureForFunctionLikeDeclaration(func); @@ -12152,7 +12817,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 157) { + if (template.parent.kind === 159) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -12160,7 +12825,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 52 && operator <= 63) { + if (operator >= 53 && operator <= 64) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } @@ -12260,32 +12925,32 @@ var ts; } var _parent = node.parent; switch (_parent.kind) { - case 193: - case 128: - case 130: + case 195: case 129: - case 150: + case 132: + case 131: + case 152: return getContextualTypeForInitializerExpression(node); - case 161: - case 186: + case 163: + case 188: return getContextualTypeForReturnExpression(node); - case 155: - case 156: - return getContextualTypeForArgument(_parent, node); + case 157: case 158: + return getContextualTypeForArgument(_parent, node); + case 160: return getTypeFromTypeNode(_parent.type); - case 167: + case 169: return getContextualTypeForBinaryOperand(node); - case 218: + case 221: return getContextualTypeForObjectLiteralElement(_parent); - case 151: + case 153: return getContextualTypeForElementExpression(node); - case 168: + case 170: return getContextualTypeForConditionalOperand(node); - case 173: - ts.Debug.assert(_parent.parent.kind === 169); + case 175: + ts.Debug.assert(_parent.parent.kind === 171); return getContextualTypeForSubstitutionExpression(_parent.parent, node); - case 159: + case 161: return getContextualType(_parent); } return undefined; @@ -12300,13 +12965,13 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 160 || node.kind === 161; + return node.kind === 162 || node.kind === 163; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -12350,13 +13015,13 @@ var ts; } function isAssignmentTarget(node) { var _parent = node.parent; - if (_parent.kind === 167 && _parent.operatorToken.kind === 52 && _parent.left === node) { + if (_parent.kind === 169 && _parent.operatorToken.kind === 53 && _parent.left === node) { return true; } - if (_parent.kind === 218) { + if (_parent.kind === 221) { return isAssignmentTarget(_parent.parent); } - if (_parent.kind === 151) { + if (_parent.kind === 153) { return isAssignmentTarget(_parent); } return false; @@ -12378,7 +13043,7 @@ var ts; var elementTypes = []; ts.forEach(elements, function (e) { var type = checkExpression(e, contextualMapper); - if (e.kind === 171) { + if (e.kind === 173) { elementTypes.push(getIndexTypeOfType(type, 1) || anyType); hasSpreadElement = true; } @@ -12395,7 +13060,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 126 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 127 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return allConstituentTypesHaveKind(checkComputedPropertyName(name), 1 | 132); @@ -12425,19 +13090,19 @@ var ts; for (var _i = 0, _a = node.properties, _n = _a.length; _i < _n; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 218 || - memberDecl.kind === 219 || + if (memberDecl.kind === 221 || + memberDecl.kind === 222 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 218) { + if (memberDecl.kind === 221) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 132) { + else if (memberDecl.kind === 134) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 219); - type = memberDecl.name.kind === 126 + ts.Debug.assert(memberDecl.kind === 222); + type = memberDecl.name.kind === 127 ? unknownType : checkExpression(memberDecl.name, contextualMapper); } @@ -12453,7 +13118,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 134 || memberDecl.kind === 135); + ts.Debug.assert(memberDecl.kind === 136 || memberDecl.kind === 137); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -12486,7 +13151,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 130; + return s.valueDeclaration ? s.valueDeclaration.kind : 132; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -12496,7 +13161,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 196); + var enclosingClassDeclaration = ts.getAncestor(node, 198); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -12505,7 +13170,7 @@ var ts; } return; } - if (left.kind === 90) { + if (left.kind === 91) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -12543,7 +13208,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 90 && getDeclarationKindFromSymbol(prop) !== 132) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -12555,14 +13220,14 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 153 + var left = node.kind === 155 ? node.expression : node.left; var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 90 && getDeclarationKindFromSymbol(prop) !== 132) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { return false; } else { @@ -12577,7 +13242,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 156 && node.parent.expression === node) { + if (node.parent.kind === 158 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -12673,7 +13338,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 157) { + if (node.kind === 159) { checkExpression(node.template); } else { @@ -12726,7 +13391,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 171) { + if (args[i].kind === 173) { return i; } } @@ -12736,11 +13401,11 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 157) { + if (node.kind === 159) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 169) { + if (tagExpression.template.kind === 171) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -12755,7 +13420,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 156); + ts.Debug.assert(callExpression.kind === 158); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -12794,42 +13459,42 @@ var ts; }); return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature, args, excludeArgument) { + function inferTypeArguments(signature, args, excludeArgument, context) { var typeParameters = signature.typeParameters; - var context = createInferenceContext(typeParameters, false); var inferenceMapper = createInferenceMapper(context); - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 172) { - var paramType = getTypeAtPosition(signature, arg.kind === 171 ? -1 : i); + for (var i = 0; i < typeParameters.length; i++) { + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind !== 174) { + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : _i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 157) { + if (_i === 0 && args[_i].parent.kind === 159) { argType = globalTemplateStringsArrayType; } else { - var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; + var mapper = excludeArgument && excludeArgument[_i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); } inferTypes(context, argType, paramType); } } if (excludeArgument) { - for (var _i = 0; _i < args.length; _i++) { - if (excludeArgument[_i] === false) { - var _arg = args[_i]; - var _paramType = getTypeAtPosition(signature, _arg.kind === 171 ? -1 : _i); + for (var _i_1 = 0; _i_1 < args.length; _i_1++) { + if (excludeArgument[_i_1] === false) { + var _arg = args[_i_1]; + var _paramType = getTypeAtPosition(signature, _arg.kind === 173 ? -1 : _i_1); inferTypes(context, checkExpressionWithContextualType(_arg, _paramType, inferenceMapper), _paramType); } } } - var inferredTypes = getInferredTypes(context); - context.failedTypeParameterIndex = ts.indexOf(inferredTypes, inferenceFailureType); - for (var _i_1 = 0; _i_1 < inferredTypes.length; _i_1++) { - if (inferredTypes[_i_1] === inferenceFailureType) { - inferredTypes[_i_1] = unknownType; - } - } - return context; + getInferredTypes(context); } function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { var typeParameters = signature.typeParameters; @@ -12850,9 +13515,9 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 172) { - var paramType = getTypeAtPosition(signature, arg.kind === 171 ? -1 : i); - var argType = i === 0 && node.kind === 157 ? globalTemplateStringsArrayType : + if (arg.kind !== 174) { + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); + var argType = i === 0 && node.kind === 159 ? globalTemplateStringsArrayType : arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { @@ -12864,10 +13529,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 157) { + if (node.kind === 159) { var template = node.template; args = [template]; - if (template.kind === 169) { + if (template.kind === 171) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -12879,8 +13544,8 @@ var ts; return args; } function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 90) { - var containingClass = ts.getAncestor(callExpression, 196); + if (callExpression.expression.kind === 91) { + var containingClass = ts.getAncestor(callExpression, 198); var baseClassTypeNode = containingClass && ts.getClassBaseTypeNode(containingClass); return baseClassTypeNode && baseClassTypeNode.typeArguments; } @@ -12889,11 +13554,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 157; + var isTaggedTemplate = node.kind === 159; var typeArguments; if (!isTaggedTemplate) { typeArguments = getEffectiveTypeArguments(node); - if (node.expression.kind !== 90) { + if (node.expression.kind !== 91) { ts.forEach(typeArguments, checkSourceElement); } } @@ -12958,14 +13623,15 @@ var ts; return resolveErrorCall(node); function chooseOverload(candidates, relation) { for (var _a = 0, _b = candidates.length; _a < _b; _a++) { - var current = candidates[_a]; - if (!hasCorrectArity(node, args, current)) { + var originalCandidate = candidates[_a]; + if (!hasCorrectArity(node, args, originalCandidate)) { continue; } - var originalCandidate = current; - var inferenceResult = void 0; var _candidate = void 0; var typeArgumentsAreValid = void 0; + var inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, false) + : undefined; while (true) { _candidate = originalCandidate; if (_candidate.typeParameters) { @@ -12975,9 +13641,9 @@ var ts; typeArgumentsAreValid = checkTypeArguments(_candidate, typeArguments, typeArgumentTypes, false); } else { - inferenceResult = inferTypeArguments(_candidate, args, excludeArgument); - typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0; - typeArgumentTypes = inferenceResult.inferredTypes; + inferTypeArguments(_candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; } if (!typeArgumentsAreValid) { break; @@ -13001,7 +13667,7 @@ var ts; else { candidateForTypeArgumentError = originalCandidate; if (!typeArguments) { - resultOfFailedInference = inferenceResult; + resultOfFailedInference = inferenceContext; } } } @@ -13014,7 +13680,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 90) { + if (node.expression.kind === 91) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1), candidatesOutArray); @@ -13098,13 +13764,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 155) { + if (node.kind === 157) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 156) { + else if (node.kind === 158) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 157) { + else if (node.kind === 159) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -13116,15 +13782,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 90) { + if (node.expression.kind === 91) { return voidType; } - if (node.kind === 156) { + if (node.kind === 158) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 133 && - declaration.kind !== 137 && - declaration.kind !== 141) { + declaration.kind !== 135 && + declaration.kind !== 139 && + declaration.kind !== 143) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -13176,7 +13842,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 174) { + if (func.body.kind !== 176) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -13214,7 +13880,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 190); + return (body.statements.length === 1) && (body.statements[0].kind === 192); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -13223,7 +13889,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 174) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 176) { return; } var bodyBlock = func.body; @@ -13236,9 +13902,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 160) { + if (!hasGrammarError && node.kind === 162) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -13266,19 +13932,19 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 132 && node.kind !== 131) { + if (produceDiagnostics && node.kind !== 134 && node.kind !== 133) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } if (node.body) { - if (node.body.kind === 174) { + if (node.body.kind === 176) { checkSourceElement(node.body); } else { @@ -13304,17 +13970,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 64: { + case 65: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 153: { + case 155: { var _symbol = findSymbol(n); return !_symbol || _symbol === unknownSymbol || (_symbol.flags & ~8) !== 0; } - case 154: + case 156: return true; - case 159: + case 161: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -13322,12 +13988,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 64: - case 153: { + case 65: + case 155: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 154: { + case 156: { var index = n.argumentExpression; var _symbol = findSymbol(n.expression); if (_symbol && index && index.kind === 8) { @@ -13337,12 +14003,25 @@ var ts; } return false; } - case 159: + case 161: return isConstVariableReference(n.expression); default: return false; } } + function isImportedNameFromExternalModule(n) { + switch (n.kind) { + case 156: + case 155: { + var symbol = findSymbol(n.expression); + return symbol && symbol.flags & 8388608 && isExternalModuleSymbol(resolveAlias(symbol)); + } + case 161: + return isImportedNameFromExternalModule(n.expression); + default: + return false; + } + } if (!isReferenceOrErrorExpression(n)) { error(n, invalidReferenceMessage); return false; @@ -13351,10 +14030,13 @@ var ts; error(n, constantVariableMessage); return false; } + if (isImportedNameFromExternalModule(n)) { + error(n, invalidReferenceMessage); + } return true; } function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 && node.expression.kind === 64) { + if (node.parserContextFlags & 1 && node.expression.kind === 65) { grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); } var operandType = checkExpression(node.expression); @@ -13462,7 +14144,7 @@ var ts; var properties = node.properties; for (var _i = 0, _n = properties.length; _i < _n; _i++) { var p = properties[_i]; - if (p.kind === 218 || p.kind === 219) { + if (p.kind === 221 || p.kind === 222) { var _name = p.name; var type = sourceType.flags & 1 ? sourceType : getTypeOfPropertyOfType(sourceType, _name.text) || @@ -13489,8 +14171,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 172) { - if (e.kind !== 171) { + if (e.kind !== 174) { + if (e.kind !== 173) { var propName = "" + i; var type = sourceType.flags & 1 ? sourceType : isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) : @@ -13520,14 +14202,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 167 && target.operatorToken.kind === 52) { + if (target.kind === 169 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 152) { + if (target.kind === 154) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 151) { + if (target.kind === 153) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -13544,32 +14226,32 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operatorToken.kind; - if (operator === 52 && (node.left.kind === 152 || node.left.kind === 151)) { + if (operator === 53 && (node.left.kind === 154 || node.left.kind === 153)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { case 35: - case 55: - case 36: case 56: - case 37: + case 36: case 57: - case 34: - case 54: - case 40: + case 37: case 58: - case 41: + case 34: + case 55: + case 40: case 59: - case 42: + case 41: case 60: - case 44: - case 62: - case 45: - case 63: - case 43: + case 42: case 61: + case 44: + case 63: + case 45: + case 64: + case 43: + case 62: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -13589,7 +14271,7 @@ var ts; } return numberType; case 33: - case 53: + case 54: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -13613,7 +14295,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 53) { + if (operator === 54) { checkAssignmentOperator(resultType); } return resultType; @@ -13632,15 +14314,15 @@ var ts; reportOperatorError(); } return booleanType; - case 86: + case 87: return checkInstanceOfExpression(node, leftType, rightType); - case 85: + case 86: return checkInExpression(node, leftType, rightType); case 48: return rightType; case 49: return getUnionType([leftType, rightType]); - case 52: + case 53: checkAssignmentOperator(rightType); return rightType; case 23: @@ -13659,20 +14341,20 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 44: - case 62: + case 63: return 49; case 45: - case 63: + case 64: return 31; case 43: - case 61: + case 62: return 48; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 52 && operator <= 63) { + if (produceDiagnostics && operator >= 53 && operator <= 64) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -13718,14 +14400,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -13751,7 +14433,7 @@ var ts; } function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 125) { + if (node.kind == 126) { type = checkQualifiedName(node); } else { @@ -13759,9 +14441,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 153 && node.parent.expression === node) || - (node.parent.kind === 154 && node.parent.expression === node) || - ((node.kind === 64 || node.kind === 125) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 155 && node.parent.expression === node) || + (node.parent.kind === 156 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 126) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -13774,65 +14456,65 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 64: + case 65: return checkIdentifier(node); - case 92: + case 93: return checkThisExpression(node); - case 90: + case 91: return checkSuperExpression(node); - case 88: + case 89: return nullType; - case 94: - case 79: + case 95: + case 80: return booleanType; case 7: return checkNumericLiteral(node); - case 169: + case 171: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 151: - return checkArrayLiteral(node, contextualMapper); - case 152: - return checkObjectLiteral(node, contextualMapper); case 153: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 154: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 155: + return checkPropertyAccessExpression(node); case 156: - return checkCallExpression(node); + return checkIndexedAccess(node); case 157: - return checkTaggedTemplateExpression(node); case 158: - return checkTypeAssertion(node); + return checkCallExpression(node); case 159: - return checkExpression(node.expression, contextualMapper); + return checkTaggedTemplateExpression(node); case 160: + return checkTypeAssertion(node); case 161: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 163: - return checkTypeOfExpression(node); + return checkExpression(node.expression, contextualMapper); case 162: - return checkDeleteExpression(node); - case 164: - return checkVoidExpression(node); + case 163: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 165: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 164: + return checkDeleteExpression(node); case 166: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 167: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 168: - return checkConditionalExpression(node, contextualMapper); - case 171: - return checkSpreadElementExpression(node, contextualMapper); - case 172: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 169: + return checkBinaryExpression(node, contextualMapper); case 170: + return checkConditionalExpression(node, contextualMapper); + case 173: + return checkSpreadElementExpression(node, contextualMapper); + case 174: + return undefinedType; + case 172: checkYieldExpression(node); return unknownType; } @@ -13849,12 +14531,12 @@ var ts; } } function checkParameter(node) { - checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 133 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 135 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -13868,12 +14550,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 138) { + if (node.kind === 140) { checkGrammarIndexSignature(node); } - else if (node.kind === 140 || node.kind === 195 || node.kind === 141 || - node.kind === 136 || node.kind === 133 || - node.kind === 137) { + else if (node.kind === 142 || node.kind === 197 || node.kind === 143 || + node.kind === 138 || node.kind === 135 || + node.kind === 139) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -13885,10 +14567,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 137: + case 139: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 136: + case 138: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -13897,7 +14579,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 197) { + if (node.kind === 199) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -13912,7 +14594,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 120: + case 121: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -13920,7 +14602,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 118: + case 119: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -13934,7 +14616,7 @@ var ts; } } function checkPropertyDeclaration(node) { - checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); } function checkMethodDeclaration(node) { @@ -13957,30 +14639,30 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 155 && n.expression.kind === 90; + return n.kind === 157 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 160: - case 195: - case 161: - case 152: return false; + case 162: + case 197: + case 163: + case 154: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 92) { + if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 160 && n.kind !== 195) { + else if (n.kind !== 162 && n.kind !== 197) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 130 && + return n.kind === 132 && !(n.flags & 128) && !!n.initializer; } @@ -13990,7 +14672,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 177 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 179 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -14006,13 +14688,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 134) { + if (node.kind === 136) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 134 ? 135 : 134; + var otherKind = node.kind === 136 ? 137 : 136; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -14031,6 +14713,9 @@ var ts; } checkFunctionLikeDeclaration(node); } + function checkMissingDeclaration(node) { + checkDecorators(node); + } function checkTypeReference(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReferenceNode(node); @@ -14086,9 +14771,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 197) { - ts.Debug.assert(signatureDeclarationNode.kind === 136 || signatureDeclarationNode.kind === 137); - var signatureKind = signatureDeclarationNode.kind === 136 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 199) { + ts.Debug.assert(signatureDeclarationNode.kind === 138 || signatureDeclarationNode.kind === 139); + var signatureKind = signatureDeclarationNode.kind === 138 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -14106,7 +14791,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 197 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 199 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -14179,7 +14864,7 @@ var ts; if (subsequentNode.kind === node.kind) { var _errorNode = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 132 || node.kind === 131); + ts.Debug.assert(node.kind === 134 || node.kind === 133); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(_errorNode, diagnostic); @@ -14206,11 +14891,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 197 || node.parent.kind === 143 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 199 || node.parent.kind === 145 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 195 || node.kind === 132 || node.kind === 131 || node.kind === 133) { + if (node.kind === 197 || node.kind === 134 || node.kind === 133 || node.kind === 135) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -14307,16 +14992,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 197: + case 199: return 2097152; - case 200: + case 202: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 196: - case 199: + case 198: + case 201: return 2097152 | 1048576; - case 203: + case 205: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -14326,6 +15011,49 @@ var ts; } } } + function checkDecorator(node) { + var expression = node.expression; + var exprType = checkExpression(expression); + switch (node.parent.kind) { + case 198: + var classSymbol = getSymbolOfNode(node.parent); + var classConstructorType = getTypeOfSymbol(classSymbol); + var classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + checkTypeAssignableTo(exprType, classDecoratorType, node); + break; + case 132: + checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + break; + case 134: + case 136: + case 137: + var methodType = getTypeOfNode(node.parent); + var methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + checkTypeAssignableTo(exprType, methodDecoratorType, node); + break; + case 129: + checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + break; + } + } + function checkDecorators(node) { + if (!node.decorators) { + return; + } + switch (node.kind) { + case 198: + case 134: + case 136: + case 137: + case 132: + case 129: + emitDecorate = true; + break; + default: + return; + } + ts.forEach(node.decorators, checkDecorator); + } function checkFunctionDeclaration(node) { if (produceDiagnostics) { checkFunctionLikeDeclaration(node) || @@ -14338,8 +15066,9 @@ var ts; } } function checkFunctionLikeDeclaration(node) { + checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 126) { + if (node.name && node.name.kind === 127) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -14364,11 +15093,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 174) { + if (node.kind === 176) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 201) { + if (ts.isFunctionBlock(node) || node.kind === 203) { checkFunctionExpressionBodies(node); } } @@ -14386,19 +15115,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 130 || - node.kind === 129 || - node.kind === 132 || + if (node.kind === 132 || node.kind === 131 || node.kind === 134 || - node.kind === 135) { + node.kind === 133 || + node.kind === 136 || + node.kind === 137) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = getRootDeclaration(node); - if (root.kind === 128 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 129 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -14412,7 +15141,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var _isDeclaration = node.kind !== 64; + var _isDeclaration = node.kind !== 65; if (_isDeclaration) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -14428,12 +15157,12 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 196); + var enclosingClass = ts.getAncestor(node, 198); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } if (ts.getClassBaseTypeNode(enclosingClass)) { - var _isDeclaration = node.kind !== 64; + var _isDeclaration = node.kind !== 65; if (_isDeclaration) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -14446,56 +15175,62 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 200 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 202 && ts.getModuleInstanceState(node) !== 1) { return; } var _parent = getDeclarationContainer(node); - if (_parent.kind === 221 && ts.isExternalModule(_parent)) { + if (_parent.kind === 224 && ts.isExternalModule(_parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkVarDeclaredNamesNotShadowed(node) { - if (node.initializer && (ts.getCombinedNodeFlags(node) & 12288) === 0) { - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); - if (localDeclarationSymbol && - localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 194); - var container = varDeclList.parent.kind === 175 && - varDeclList.parent.parent; - var namesShareScope = container && - (container.kind === 174 && ts.isFunctionLike(container.parent) || - (container.kind === 201 && container.kind === 200) || - container.kind === 221); - if (!namesShareScope) { - var _name = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, _name, _name); - } + if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || isParameterDeclaration(node)) { + return; + } + if (node.kind === 195 && !node.initializer) { + return; + } + var symbol = getSymbolOfNode(node); + if (symbol.flags & 1) { + var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); + if (localDeclarationSymbol && + localDeclarationSymbol !== symbol && + localDeclarationSymbol.flags & 2) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 196); + var container = varDeclList.parent.kind === 177 && varDeclList.parent.parent + ? varDeclList.parent.parent + : undefined; + var namesShareScope = container && + (container.kind === 176 && ts.isFunctionLike(container.parent) || + container.kind === 203 || + container.kind === 202 || + container.kind === 224); + if (!namesShareScope) { + var _name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, _name, _name); } } } } } function isParameterDeclaration(node) { - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent.parent; } - return node.kind === 128; + return node.kind === 129; } function checkParameterInitializer(node) { - if (getRootDeclaration(node).kind !== 128) { + if (getRootDeclaration(node).kind !== 129) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 64) { + if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 128) { + if (referencedSymbol.valueDeclaration.kind === 129) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -14513,8 +15248,9 @@ var ts; } } function checkVariableLikeDeclaration(node) { + checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -14523,7 +15259,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && getRootDeclaration(node).kind === 128 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && getRootDeclaration(node).kind === 129 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -14551,9 +15287,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 130 && node.kind !== 129) { + if (node.kind !== 132 && node.kind !== 131) { checkExportsOnMergedDeclarations(node); - if (node.kind === 193 || node.kind === 150) { + if (node.kind === 195 || node.kind === 152) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -14570,7 +15306,7 @@ var ts; return checkVariableLikeDeclaration(node); } function checkVariableStatement(node) { - checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + checkGrammarDecorators(node) || checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) { @@ -14582,7 +15318,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 174 || node.kind === 152) { + if (node.kind === 176 || node.kind === 154) { return true; } node = node.parent; @@ -14610,12 +15346,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 194) { + if (node.initializer && node.initializer.kind == 196) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -14630,13 +15366,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 151 || varExpr.kind === 152) { + if (varExpr.kind === 153 || varExpr.kind === 154) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -14651,7 +15387,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -14661,7 +15397,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 151 || varExpr.kind === 152) { + if (varExpr.kind === 153 || varExpr.kind === 154) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!allConstituentTypesHaveKind(leftType, 1 | 258)) { @@ -14780,7 +15516,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 134 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 135))); + return !!(node.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 137))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -14794,11 +15530,11 @@ var ts; if (func) { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); var exprType = checkExpressionCached(node.expression); - if (func.kind === 135) { + if (func.kind === 137) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - if (func.kind === 133) { + if (func.kind === 135) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -14825,7 +15561,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 215 && !hasDuplicateDefaultClause) { + if (clause.kind === 218 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -14837,7 +15573,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 214) { + if (produceDiagnostics && clause.kind === 217) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -14854,7 +15590,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 189 && current.label.text === node.label.text) { + if (current.kind === 191 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -14880,7 +15616,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 64) { + if (catchClause.variableDeclaration.name.kind !== 65) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -14918,7 +15654,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 196) { + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 198) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members, _n = _a.length; _i < _n; _i++) { var member = _a[_i]; @@ -14949,7 +15685,7 @@ var ts; return; } var _errorNode; - if (prop.valueDeclaration.name.kind === 126 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 127 || prop.parent === containingType.symbol) { _errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -14995,6 +15731,7 @@ var ts; } function checkClassDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); + checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); @@ -15095,7 +15832,7 @@ var ts; } } function isAccessor(kind) { - return kind === 134 || kind === 135; + return kind === 136 || kind === 137; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -15154,13 +15891,13 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 197); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 199); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15183,7 +15920,7 @@ var ts; } } function checkTypeAliasDeclaration(node) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); } @@ -15196,12 +15933,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 126 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 127 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); + autoValue = getConstantValueForEnumMemberInitializer(initializer); if (autoValue === undefined) { if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); @@ -15228,11 +15965,11 @@ var ts; }); _nodeLinks.flags |= 128; } - function getConstantValueForEnumMemberInitializer(initializer, enumIsConst) { + function getConstantValueForEnumMemberInitializer(initializer) { return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 165: + case 167: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -15240,13 +15977,10 @@ var ts; switch (e.operator) { case 33: return value; case 34: return -value; - case 47: return enumIsConst ? ~value : undefined; + case 47: return ~value; } return undefined; - case 167: - if (!enumIsConst) { - return undefined; - } + case 169: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -15271,36 +16005,47 @@ var ts; return undefined; case 7: return +e.text; - case 159: - return enumIsConst ? evalConstant(e.expression) : undefined; - case 64: - case 154: - case 153: - if (!enumIsConst) { - return undefined; - } + case 161: + return evalConstant(e.expression); + case 65: + case 156: + case 155: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var _enumType; var propertyName; - if (e.kind === 64) { + if (e.kind === 65) { _enumType = currentType; propertyName = e.text; } else { - if (e.kind === 154) { + var expression; + if (e.kind === 156) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; } - _enumType = getTypeOfNode(e.expression); + expression = e.expression; propertyName = e.argumentExpression.text; } else { - _enumType = getTypeOfNode(e.expression); + expression = e.expression; propertyName = e.name.text; } - if (_enumType !== currentType) { + var current = expression; + while (current) { + if (current.kind === 65) { + break; + } + else if (current.kind === 155) { + current = current.expression; + } + else { + return undefined; + } + } + _enumType = checkExpression(expression); + if (!(_enumType.symbol && (_enumType.symbol.flags & 384))) { return undefined; } } @@ -15327,7 +16072,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -15346,7 +16091,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 199) { + if (declaration.kind !== 201) { return false; } var enumDeclaration = declaration; @@ -15369,7 +16114,7 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 196 || (declaration.kind === 195 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 198 || (declaration.kind === 197 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -15377,7 +16122,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarModifiers(node)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -15412,7 +16157,7 @@ var ts; checkSourceElement(node.body); } function getFirstIdentifier(node) { - while (node.kind === 125) { + while (node.kind === 126) { node = node.left; } return node; @@ -15423,9 +16168,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 201 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 221 && !inAmbientExternalModule) { - error(moduleName, node.kind === 210 ? + var inAmbientExternalModule = node.parent.kind === 203 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 224 && !inAmbientExternalModule) { + error(moduleName, node.kind === 212 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module : ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); return false; @@ -15444,7 +16189,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 212 ? + var message = node.kind === 214 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -15457,7 +16202,7 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -15467,7 +16212,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { checkImportBinding(importClause.namedBindings); } else { @@ -15478,7 +16223,7 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -15498,15 +16243,30 @@ var ts; } } } + else { + if (languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + } + } } } function checkExportDeclaration(node) { - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); + var inAmbientExternalModule = node.parent.kind === 203 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 224 && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + } + } + else { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, ts.Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } } } } @@ -15517,67 +16277,58 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 221 ? node.parent : node.parent.parent; - if (container.kind === 200 && container.name.kind === 64) { + var container = node.parent.kind === 224 ? node.parent : node.parent.parent; + if (container.kind === 202 && container.name.kind === 65) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); return; } - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 64) { - markExportAsReferenced(node); + if (node.expression) { + if (node.expression.kind === 65) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } } - else { - checkExpressionCached(node.expression); + if (node.type) { + checkSourceElement(node.type); + if (!ts.isInAmbientContext(node)) { + grammarErrorOnFirstToken(node.type, ts.Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration); + } } checkExternalModuleExports(container); + if (node.isExportEquals && languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } } function getModuleStatements(node) { - if (node.kind === 221) { + if (node.kind === 224) { return node.statements; } - if (node.kind === 200 && node.body.kind === 201) { + if (node.kind === 202 && node.body.kind === 203) { return node.body.statements; } return emptyArray; } function hasExportedMembers(moduleSymbol) { - var declarations = moduleSymbol.declarations; - for (var _i = 0, _n = declarations.length; _i < _n; _i++) { - var current = declarations[_i]; - var statements = getModuleStatements(current); - for (var _a = 0, _b = statements.length; _a < _b; _a++) { - var node = statements[_a]; - if (node.kind === 210) { - var exportClause = node.exportClause; - if (!exportClause) { - return true; - } - var specifiers = exportClause.elements; - for (var _c = 0, _d = specifiers.length; _c < _d; _c++) { - var specifier = specifiers[_c]; - if (!(specifier.propertyName && specifier.name && specifier.name.text === "default")) { - return true; - } - } - } - else if (node.kind !== 209 && node.flags & 1 && !(node.flags & 256)) { - return true; - } + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; } } + return false; } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - if (hasExportedMembers(moduleSymbol)) { - var declaration = getDeclarationOfAliasSymbol(defaultSymbol) || defaultSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } + var exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } links.exportsChecked = true; } @@ -15586,162 +16337,162 @@ var ts; if (!node) return; switch (node.kind) { - case 127: - return checkTypeParameter(node); case 128: - return checkParameter(node); - case 130: + return checkTypeParameter(node); case 129: - return checkPropertyDeclaration(node); - case 140: - case 141: - case 136: - case 137: - return checkSignatureDeclaration(node); - case 138: - return checkSignatureDeclaration(node); + return checkParameter(node); case 132: case 131: - return checkMethodDeclaration(node); - case 133: - return checkConstructorDeclaration(node); - case 134: - case 135: - return checkAccessorDeclaration(node); - case 139: - return checkTypeReference(node); + return checkPropertyDeclaration(node); case 142: - return checkTypeQuery(node); case 143: - return checkTypeLiteral(node); + case 138: + case 139: + return checkSignatureDeclaration(node); + case 140: + return checkSignatureDeclaration(node); + case 134: + case 133: + return checkMethodDeclaration(node); + case 135: + return checkConstructorDeclaration(node); + case 136: + case 137: + return checkAccessorDeclaration(node); + case 141: + return checkTypeReference(node); case 144: - return checkArrayType(node); + return checkTypeQuery(node); case 145: - return checkTupleType(node); + return checkTypeLiteral(node); case 146: - return checkUnionType(node); + return checkArrayType(node); case 147: + return checkTupleType(node); + case 148: + return checkUnionType(node); + case 149: return checkSourceElement(node.type); - case 195: - return checkFunctionDeclaration(node); - case 174: - case 201: - return checkBlock(node); - case 175: - return checkVariableStatement(node); - case 177: - return checkExpressionStatement(node); - case 178: - return checkIfStatement(node); - case 179: - return checkDoStatement(node); - case 180: - return checkWhileStatement(node); - case 181: - return checkForStatement(node); - case 182: - return checkForInStatement(node); - case 183: - return checkForOfStatement(node); - case 184: - case 185: - return checkBreakOrContinueStatement(node); - case 186: - return checkReturnStatement(node); - case 187: - return checkWithStatement(node); - case 188: - return checkSwitchStatement(node); - case 189: - return checkLabeledStatement(node); - case 190: - return checkThrowStatement(node); - case 191: - return checkTryStatement(node); - case 193: - return checkVariableDeclaration(node); - case 150: - return checkBindingElement(node); - case 196: - return checkClassDeclaration(node); case 197: - return checkInterfaceDeclaration(node); - case 198: - return checkTypeAliasDeclaration(node); - case 199: - return checkEnumDeclaration(node); - case 200: - return checkModuleDeclaration(node); - case 204: - return checkImportDeclaration(node); - case 203: - return checkImportEqualsDeclaration(node); - case 210: - return checkExportDeclaration(node); - case 209: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 176: - checkGrammarStatementInAmbientContext(node); - return; + case 203: + return checkBlock(node); + case 177: + return checkVariableStatement(node); + case 179: + return checkExpressionStatement(node); + case 180: + return checkIfStatement(node); + case 181: + return checkDoStatement(node); + case 182: + return checkWhileStatement(node); + case 183: + return checkForStatement(node); + case 184: + return checkForInStatement(node); + case 185: + return checkForOfStatement(node); + case 186: + case 187: + return checkBreakOrContinueStatement(node); + case 188: + return checkReturnStatement(node); + case 189: + return checkWithStatement(node); + case 190: + return checkSwitchStatement(node); + case 191: + return checkLabeledStatement(node); case 192: + return checkThrowStatement(node); + case 193: + return checkTryStatement(node); + case 195: + return checkVariableDeclaration(node); + case 152: + return checkBindingElement(node); + case 198: + return checkClassDeclaration(node); + case 199: + return checkInterfaceDeclaration(node); + case 200: + return checkTypeAliasDeclaration(node); + case 201: + return checkEnumDeclaration(node); + case 202: + return checkModuleDeclaration(node); + case 206: + return checkImportDeclaration(node); + case 205: + return checkImportEqualsDeclaration(node); + case 212: + return checkExportDeclaration(node); + case 211: + return checkExportAssignment(node); + case 178: checkGrammarStatementInAmbientContext(node); return; + case 194: + checkGrammarStatementInAmbientContext(node); + return; + case 215: + return checkMissingDeclaration(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 160: - case 161: + case 162: + case 163: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 132: - case 131: + case 134: + case 133: ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 133: - case 134: case 135: - case 195: + case 136: + case 137: + case 197: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 187: + case 189: checkFunctionExpressionBodies(node.expression); break; - case 128: - case 130: case 129: - case 148: - case 149: + case 132: + case 131: case 150: case 151: case 152: - case 218: case 153: case 154: + case 221: case 155: case 156: case 157: - case 169: - case 173: case 158: case 159: - case 163: - case 164: - case 162: + case 171: + case 175: + case 160: + case 161: case 165: case 166: + case 164: case 167: case 168: - case 171: - case 174: - case 201: - case 175: + case 169: + case 170: + case 173: + case 176: + case 203: case 177: - case 178: case 179: case 180: case 181: @@ -15750,21 +16501,23 @@ var ts; case 184: case 185: case 186: + case 187: case 188: - case 202: - case 214: - case 215: - case 189: case 190: - case 191: + case 204: case 217: + case 218: + case 191: + case 192: case 193: - case 194: - case 196: - case 199: case 220: - case 209: - case 221: + case 195: + case 196: + case 198: + case 201: + case 223: + case 211: + case 224: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -15792,6 +16545,9 @@ var ts; if (emitExtends) { links.flags |= 8; } + if (emitDecorate) { + links.flags |= 512; + } links.flags |= 1; } } @@ -15816,7 +16572,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 187 && node.parent.statement === node) { + if (node.parent.kind === 189 && node.parent.statement === node) { return true; } node = node.parent; @@ -15827,6 +16583,44 @@ var ts; function getSymbolsInScope(location, meaning) { var symbols = {}; var memberFlags = 0; + if (isInsideWithStatementBody(location)) { + return []; + } + populateSymbols(); + return symbolsToArray(symbols); + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + switch (location.kind) { + case 224: + if (!ts.isExternalModule(location)) { + break; + } + case 202: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); + break; + case 201: + copySymbols(getSymbolOfNode(location).exports, meaning & 8); + break; + case 198: + case 199: + if (!(memberFlags & 128)) { + copySymbols(getSymbolOfNode(location).members, meaning & 793056); + } + break; + case 162: + if (location.name) { + copySymbol(location.symbol, meaning); + } + break; + } + memberFlags = location.flags; + location = location.parent; + } + copySymbols(globals, meaning); + } function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; @@ -15852,22 +16646,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 221: + case 224: if (!ts.isExternalModule(location)) break; - case 200: + case 202: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 199: + case 201: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 196: - case 197: + case 198: + case 199: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 160: + case 162: if (location.name) { copySymbol(location.symbol, meaning); } @@ -15877,97 +16671,97 @@ var ts; location = location.parent; } copySymbols(globals, meaning); - return ts.mapToArray(symbols); + return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 64 && + return name.kind == 65 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 127: - case 196: - case 197: + case 128: case 198: case 199: + case 200: + case 201: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 125) + while (node.parent && node.parent.kind === 126) node = node.parent; - return node.parent && node.parent.kind === 139; + return node.parent && node.parent.kind === 141; } function isTypeNode(node) { - if (139 <= node.kind && node.kind <= 147) { + if (141 <= node.kind && node.kind <= 149) { return true; } switch (node.kind) { - case 111: - case 118: - case 120: case 112: + case 119: case 121: + case 113: + case 122: return true; - case 98: - return node.parent.kind !== 164; + case 99: + return node.parent.kind !== 166; case 8: - return node.parent.kind === 128; - case 64: - if (node.parent.kind === 125 && node.parent.right === node) { + return node.parent.kind === 129; + case 65: + if (node.parent.kind === 126 && node.parent.right === node) { node = node.parent; } - case 125: - ts.Debug.assert(node.kind === 64 || node.kind === 125, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + case 126: + ts.Debug.assert(node.kind === 65 || node.kind === 126, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var _parent = node.parent; - if (_parent.kind === 142) { + if (_parent.kind === 144) { return false; } - if (139 <= _parent.kind && _parent.kind <= 147) { + if (141 <= _parent.kind && _parent.kind <= 149) { return true; } switch (_parent.kind) { - case 127: - return node === _parent.constraint; - case 130: - case 129: case 128: - case 193: - return node === _parent.type; - case 195: - case 160: - case 161: - case 133: + return node === _parent.constraint; case 132: case 131: - case 134: - case 135: + case 129: + case 195: return node === _parent.type; + case 197: + case 162: + case 163: + case 135: + case 134: + case 133: case 136: case 137: + return node === _parent.type; case 138: + case 139: + case 140: return node === _parent.type; - case 158: + case 160: return node === _parent.type; - case 155: - case 156: - return _parent.typeArguments && ts.indexOf(_parent.typeArguments, node) >= 0; case 157: + case 158: + return _parent.typeArguments && ts.indexOf(_parent.typeArguments, node) >= 0; + case 159: return false; } } return false; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 125) { + while (nodeOnRightSide.parent.kind === 126) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 203) { + if (nodeOnRightSide.parent.kind === 205) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209) { + if (nodeOnRightSide.parent.kind === 211) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -15976,17 +16770,17 @@ var ts; return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 125 && node.parent.right === node) || - (node.parent.kind === 153 && node.parent.name === node); + return (node.parent.kind === 126 && node.parent.right === node) || + (node.parent.kind === 155 && node.parent.name === node); } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 209) { + if (entityName.parent.kind === 211) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 153) { + if (entityName.kind !== 155) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -15998,18 +16792,18 @@ var ts; if (ts.getFullWidth(entityName) === 0) { return undefined; } - if (entityName.kind === 64) { + if (entityName.kind === 65) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 153) { + else if (entityName.kind === 155) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 125) { + else if (entityName.kind === 126) { var _symbol = getNodeLinks(entityName).resolvedSymbol; if (!_symbol) { checkQualifiedName(entityName); @@ -16018,7 +16812,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var _meaning = entityName.parent.kind === 139 ? 793056 : 1536; + var _meaning = entityName.parent.kind === 141 ? 793056 : 1536; _meaning |= 8388608; return resolveEntityName(entityName, _meaning); } @@ -16031,23 +16825,23 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 64 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 209 + if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 211 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { - case 64: - case 153: - case 125: + case 65: + case 155: + case 126: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 92: - case 90: + case 93: + case 91: var type = checkExpression(node); return type.symbol; - case 113: + case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 133) { + if (constructorDeclaration && constructorDeclaration.kind === 135) { return constructorDeclaration.parent.symbol; } return undefined; @@ -16055,12 +16849,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 204 || node.parent.kind === 210) && + ((node.parent.kind === 206 || node.parent.kind === 212) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 154 && node.parent.argumentExpression === node) { + if (node.parent.kind == 156 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -16074,7 +16868,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 219) { + if (location && location.kind === 222) { return resolveEntityName(location.name, 107455); } return undefined; @@ -16148,160 +16942,73 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 221; + return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 224; } - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; + function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { + if (languageVersion >= 2) { + return undefined; } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } + var node = getDeclarationOfAliasSymbol(symbol); + if (node) { + if (node.kind === 207) { + return getGeneratedNameForNode(node.parent) + ".default"; } - } - return true; - } - function getGeneratedNamesForSourceFile(sourceFile) { - var links = getNodeLinks(sourceFile); - var generatedNames = links.generatedNames; - if (!generatedNames) { - generatedNames = links.generatedNames = {}; - generateNames(sourceFile); - } - return generatedNames; - function generateNames(node) { - switch (node.kind) { - case 195: - case 196: - generateNameForFunctionOrClassDeclaration(node); - break; - case 200: - generateNameForModuleOrEnum(node); - generateNames(node.body); - break; - case 199: - generateNameForModuleOrEnum(node); - break; - case 204: - generateNameForImportDeclaration(node); - break; - case 210: - generateNameForExportDeclaration(node); - break; - case 209: - generateNameForExportAssignment(node); - break; - case 221: - case 201: - ts.forEach(node.statements, generateNames); - break; - } - } - function isExistingName(name) { - return ts.hasProperty(globals, name) || ts.hasProperty(sourceFile.identifiers, name) || ts.hasProperty(generatedNames, name); - } - function makeUniqueName(baseName) { - var _name = ts.generateUniqueName(baseName, isExistingName); - return generatedNames[_name] = _name; - } - function assignGeneratedName(node, name) { - getNodeLinks(node).generatedName = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } - function generateNameForModuleOrEnum(node) { - if (node.name.kind === 64) { - var _name = node.name.text; - assignGeneratedName(node, isUniqueLocalName(_name, node) ? _name : makeUniqueName(_name)); - } - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); - } - function generateNameForImportDeclaration(node) { - if (node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 207) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression.kind !== 64) { - assignGeneratedName(node, makeUniqueName("default")); + if (node.kind === 210) { + var moduleName = getGeneratedNameForNode(node.parent.parent.parent); + var propertyName = node.propertyName || node.name; + return moduleName + "." + ts.unescapeIdentifier(propertyName.text); } } } - function getGeneratedNameForNode(node) { - var links = getNodeLinks(node); - if (!links.generatedName) { - getGeneratedNamesForSourceFile(getSourceFile(node)); - } - return links.generatedName; - } - function getLocalNameOfContainer(container) { - return getGeneratedNameForNode(container); - } - function getLocalNameForImportDeclaration(node) { - return getGeneratedNameForNode(node); - } - function getAliasNameSubstitution(symbol) { - var declaration = getDeclarationOfAliasSymbol(symbol); - if (declaration && declaration.kind === 208) { - var moduleName = getGeneratedNameForNode(declaration.parent.parent.parent); - var propertyName = declaration.propertyName || declaration.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - function getExportNameSubstitution(symbol, location) { + function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { if (isExternalModuleSymbol(symbol.parent)) { + if (languageVersion >= 2) { + return undefined; + } return "exports." + ts.unescapeIdentifier(symbol.name); } var node = location; var containerSymbol = getParentOfSymbol(symbol); while (node) { - if ((node.kind === 200 || node.kind === 199) && getSymbolOfNode(node) === containerSymbol) { + if ((node.kind === 202 || node.kind === 201) && getSymbolOfNode(node) === containerSymbol) { return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); } node = node.parent; } } - function getExpressionNameSubstitution(node) { - var symbol = getNodeLinks(node).resolvedSymbol; + function getExpressionNameSubstitution(node, getGeneratedNameForNode) { + var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); if (symbol) { if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent); + return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); } var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (symbol !== exportSymbol && !(exportSymbol.flags & 944)) { - return getExportNameSubstitution(exportSymbol, node.parent); + return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); } if (symbol.flags & 8388608) { - return getAliasNameSubstitution(symbol); + return getAliasNameSubstitution(symbol, getGeneratedNameForNode); } } } - function hasExportDefaultValue(node) { - var symbol = getResolvedExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbol !== unknownSymbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol); + function isValueAliasDeclaration(node) { + switch (node.kind) { + case 205: + case 207: + case 208: + case 210: + case 214: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 212: + var exportClause = node.exportClause; + return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 211: + return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 221 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 224 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } return isAliasResolvedToValue(getSymbolOfNode(node)); @@ -16313,14 +17020,17 @@ var ts; function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; } - function isReferencedAliasDeclaration(node) { - if (isAliasSymbolDeclaration(node)) { + function isReferencedAliasDeclaration(node, checkChildren) { + if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { return true; } } - return ts.forEachChild(node, isReferencedAliasDeclaration); + if (checkChildren) { + return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + } + return false; } function isImplementationOfOverload(node) { if (ts.nodeIsPresent(node.body)) { @@ -16339,15 +17049,13 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 220) { + if (node.kind === 223) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8)) { - var declaration = symbol.valueDeclaration; - var constantValue; - if (declaration.kind === 220) { - return getEnumMemberValue(declaration); + if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); } } return undefined; @@ -16363,42 +17071,48 @@ var ts; var signature = getSignatureFromDeclaration(signatureDeclaration); getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } - function isUnknownIdentifier(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "isUnknownIdentifier called with a synthesized location"); - return !resolveName(location, name, 107455, undefined, undefined) && - !ts.hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name); + function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function hasGlobalName(name) { + return ts.hasProperty(globals, name); + } + function resolvesToSomeValue(location, name) { + ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); + return !!resolveName(location, name, 107455, undefined, undefined); } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - if (n.parent.kind === 153 && - n.parent.name === n) { - return undefined; - } - if (n.parent.kind === 150 && - n.parent.propertyName === n) { - return undefined; - } - var declarationSymbol = (n.parent.kind === 193 && n.parent.name === n) || - n.parent.kind === 150 - ? getSymbolOfNode(n.parent) - : undefined; - var symbol = declarationSymbol || + var isVariableDeclarationOrBindingElement = n.parent.kind === 152 || (n.parent.kind === 195 && n.parent.name === n); + var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 217; + symbol.valueDeclaration.parent.kind !== 220; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; } return undefined; } + function instantiateSingleCallFunctionType(functionType, typeArguments) { + if (functionType === unknownType) { + return unknownType; + } + var signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } function createResolver() { return { - getGeneratedNameForNode: getGeneratedNameForNode, getExpressionNameSubstitution: getExpressionNameSubstitution, - hasExportDefaultValue: hasExportDefaultValue, + isValueAliasDeclaration: isValueAliasDeclaration, + hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, getNodeCheckFlags: getNodeCheckFlags, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, @@ -16406,10 +17120,12 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression: writeTypeOfExpression, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - isUnknownIdentifier: isUnknownIdentifier, + resolvesToSomeValue: resolvesToSomeValue, + collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId }; } @@ -16434,6 +17150,11 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); + globalClassDecoratorType = getGlobalType("ClassDecorator"); + globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); + globalMethodDecoratorType = getGlobalType("MethodDecorator"); + globalParameterDecoratorType = getGlobalType("ParameterDecorator"); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -16447,28 +17168,46 @@ var ts; } anyArrayType = createArrayType(anyType); } + function checkGrammarDecorators(node) { + if (!node.decorators) { + return false; + } + if (!ts.nodeCanBeDecorated(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + else if (languageVersion < 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (node.kind === 136 || node.kind === 137) { + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } function checkGrammarModifiers(node) { switch (node.kind) { - case 134: + case 136: + case 137: case 135: - case 133: - case 130: - case 129: case 132: case 131: - case 138: - case 196: + case 134: + case 133: + case 140: + case 198: + case 199: + case 202: + case 201: + case 177: case 197: case 200: - case 199: - case 175: - case 195: - case 198: - case 204: - case 203: - case 210: - case 209: - case 128: + case 206: + case 205: + case 212: + case 211: + case 129: break; default: return false; @@ -16481,14 +17220,14 @@ var ts; for (var _i = 0, _a = node.modifiers, _n = _a.length; _i < _n; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 109: case 108: case 107: - case 106: var text = void 0; - if (modifier.kind === 108) { + if (modifier.kind === 109) { text = "public"; } - else if (modifier.kind === 107) { + else if (modifier.kind === 108) { text = "protected"; lastProtected = modifier; } @@ -16502,50 +17241,50 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 201 || node.parent.kind === 221) { + else if (node.parent.kind === 203 || node.parent.kind === 224) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); break; - case 109: + case 110: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 201 || node.parent.kind === 221) { + else if (node.parent.kind === 203 || node.parent.kind === 224) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; lastStatic = modifier; break; - case 77: + case 78: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 114: + case 115: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 201) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 203) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -16553,7 +17292,7 @@ var ts; break; } } - if (node.kind === 133) { + if (node.kind === 135) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -16564,13 +17303,13 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 204 || node.kind === 203) && flags & 2) { + else if ((node.kind === 206 || node.kind === 205) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 197 && flags & 2) { + else if (node.kind === 199 && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } - else if (node.kind === 128 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 129 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -16582,15 +17321,14 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters) { + function checkGrammarTypeParameterList(node, typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } if (typeParameters && typeParameters.length === 0) { var start = typeParameters.pos - "<".length; - var sourceFile = ts.getSourceFileOfNode(node); - var end = ts.skipTrivia(sourceFile.text, typeParameters.end) + ">".length; - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); + var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } } function checkGrammarParameterList(parameters) { @@ -16626,7 +17364,20 @@ var ts; } } function checkGrammarFunctionLikeDeclaration(node) { - return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); + var file = ts.getSourceFileOfNode(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + } + function checkGrammarArrowFunction(node, file) { + if (node.kind === 163) { + var arrowFunction = node; + var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + if (startLine !== endLine) { + return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); + } + } + return false; } function checkGrammarIndexSignatureParameters(node) { var parameter = node.parameters[0]; @@ -16653,7 +17404,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 120 && parameter.type.kind !== 118) { + if (parameter.type.kind !== 121 && parameter.type.kind !== 119) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -16666,7 +17417,7 @@ var ts; } } function checkGrammarIndexSignature(node) { - checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); } function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { if (typeArguments && typeArguments.length === 0) { @@ -16685,7 +17436,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, _n = arguments.length; _i < _n; _i++) { var arg = arguments[_i]; - if (arg.kind === 172) { + if (arg.kind === 174) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -16709,10 +17460,10 @@ var ts; function checkGrammarClassDeclarationHeritageClauses(node) { var seenExtendsClause = false; var seenImplementsClause = false; - if (!checkGrammarModifiers(node) && node.heritageClauses) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses, _n = _a.length; _i < _n; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 78) { + if (heritageClause.token === 79) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -16725,7 +17476,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -16740,14 +17491,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses, _n = _a.length; _i < _n; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 78) { + if (heritageClause.token === 79) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -16756,11 +17507,11 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 126) { + if (node.kind !== 127) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 167 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 169 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -16787,26 +17538,26 @@ var ts; for (var _i = 0, _a = node.properties, _n = _a.length; _i < _n; _i++) { var prop = _a[_i]; var _name = prop.name; - if (prop.kind === 172 || - _name.kind === 126) { + if (prop.kind === 174 || + _name.kind === 127) { checkGrammarComputedPropertyName(_name); continue; } var currentKind = void 0; - if (prop.kind === 218 || prop.kind === 219) { + if (prop.kind === 221 || prop.kind === 222) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (_name.kind === 7) { checkGrammarNumbericLiteral(_name); } currentKind = Property; } - else if (prop.kind === 132) { + else if (prop.kind === 134) { currentKind = Property; } - else if (prop.kind === 134) { + else if (prop.kind === 136) { currentKind = GetAccessor; } - else if (prop.kind === 135) { + else if (prop.kind === 137) { currentKind = SetAccesor; } else { @@ -16840,24 +17591,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 194) { + if (forInOrOfStatement.initializer.kind === 196) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var _diagnostic = forInOrOfStatement.kind === 182 + var _diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, _diagnostic); } if (firstDeclaration.type) { - var _diagnostic_1 = forInOrOfStatement.kind === 182 + var _diagnostic_1 = forInOrOfStatement.kind === 184 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, _diagnostic_1); @@ -16880,10 +17631,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 134 && accessor.parameters.length) { + else if (kind === 136 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 135) { + else if (kind === 137) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -16908,7 +17659,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 126 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 127 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -16918,7 +17669,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 152) { + if (node.parent.kind === 154) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -16926,7 +17677,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 196) { + if (node.parent.kind === 198) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -16937,22 +17688,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 197) { + else if (node.parent.kind === 199) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 143) { + else if (node.parent.kind === 145) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 183: + case 184: + case 185: case 181: case 182: - case 183: - case 179: - case 180: return true; - case 189: + case 191: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -16964,9 +17715,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 189: + case 191: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 184 + var isMisplacedContinueLabel = node.kind === 186 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -16974,8 +17725,8 @@ var ts; return false; } break; - case 188: - if (node.kind === 185 && !node.label) { + case 190: + if (node.kind === 187 && !node.label) { return false; } break; @@ -16988,13 +17739,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 185 + var message = node.kind === 187 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var _message = node.kind === 185 + var _message = node.kind === 187 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, _message); @@ -17013,7 +17764,7 @@ var ts; return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 182 && node.parent.parent.kind !== 183) { + if (node.parent.parent.kind !== 184 && node.parent.parent.kind !== 185) { if (ts.isInAmbientContext(node)) { if (ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); @@ -17037,7 +17788,7 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 64) { + if (name.kind === 65) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -17061,15 +17812,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 178: - case 179: case 180: - case 187: case 181: case 182: - case 183: - return false; case 189: + case 183: + case 184: + case 185: + return false; + case 191: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -17085,7 +17836,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 165) { + if (expression.kind === 167) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -17104,7 +17855,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members, _n = _a.length; _i < _n; _i++) { var node = _a[_i]; - if (node.name.kind === 126) { + if (node.name.kind === 127) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -17147,7 +17898,7 @@ var ts; } } function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 64) { + if (name && name.kind === 65) { var identifier = name; if (contextNode && (contextNode.parserContextFlags & 1) && ts.isEvalOrArgumentsIdentifier(identifier)) { var nameText = ts.declarationNameToString(identifier); @@ -17166,18 +17917,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 196) { + if (node.parent.kind === 198) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 197) { + else if (node.parent.kind === 199) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 143) { + else if (node.parent.kind === 145) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -17187,12 +17938,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 197 || - node.kind === 204 || - node.kind === 203 || - node.kind === 210 || - node.kind === 209 || - (node.flags & 2)) { + if (node.kind === 199 || + node.kind === 206 || + node.kind === 205 || + node.kind === 212 || + node.kind === 211 || + (node.flags & 2) || + (node.flags & (1 | 256))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -17200,7 +17952,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements, _n = _a.length; _i < _n; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 175) { + if (ts.isDeclaration(decl) || decl.kind === 177) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -17219,7 +17971,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 174 || node.parent.kind === 201 || node.parent.kind === 221) { + if (node.parent.kind === 176 || node.parent.kind === 203 || node.parent.kind === 224) { var _links = getNodeLinks(node.parent); if (!_links.hasReportedStatementInAmbientContext) { return _links.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -17254,249 +18006,13 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!ts.isDeclarationFile(sourceFile)) { - if ((ts.isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - return true; - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(ts.getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - var lineCount = ts.getLineStarts(currentSourceFile).length; - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : ts.getStartPositionOfLine(currentLine + 1, currentSourceFile); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(ts.getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 133 && ts.nodeIsPresent(member.body)) { - return member; - } - }); - } - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var getAccessor; - var setAccessor; - if (ts.hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 134) { - getAccessor = accessor; - } - else if (accessor.kind === 135) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 134 || member.kind === 135) - && (member.flags & 128) === (accessor.flags & 128)) { - var memberName = ts.getPropertyNameForPropertyNameNode(member.name); - var accessorName = ts.getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 134 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 135 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); + function getDeclarationDiagnostics(host, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); @@ -17512,7 +18028,8 @@ var ts; var reportedDeclarationError = false; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; - var aliasDeclarationEmitInfo = []; + var moduleElementDeclarationEmitInfo = []; + var asynchronousSubModuleDeclarationEmitInfo; var referencePathsOutput = ""; if (root) { if (!compilerOptions.noResolve) { @@ -17520,25 +18037,38 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); if (referencedFile && ((referencedFile.flags & 2048) || - shouldEmitToOwnFile(referencedFile, compilerOptions) || + ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); - if (!isExternalModuleOrDeclarationFile(referencedFile)) { + if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { addedGlobalFileReference = true; } } }); } emitSourceFile(root); + if (moduleElementDeclarationEmitInfo.length) { + var oldWriter = writer; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.isVisible) { + ts.Debug.assert(aliasEmitInfo.node.kind === 206); + createAndSetNewTextWriterWithSymbolWriter(); + ts.Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } } else { var emittedReferencedFiles = []; ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { + if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { if (!compilerOptions.noResolve) { ts.forEach(sourceFile.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); - if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && + if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) { writeReferencePath(referencedFile); emittedReferencedFiles.push(referencedFile); @@ -17551,7 +18081,7 @@ var ts; } return { reportedDeclarationError: reportedDeclarationError, - aliasDeclarationEmitInfo: aliasDeclarationEmitInfo, + moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), referencePathsOutput: referencePathsOutput }; @@ -17570,7 +18100,7 @@ var ts; } } function createAndSetNewTextWriterWithSymbolWriter() { - var _writer = createTextWriter(newLine); + var _writer = ts.createTextWriter(newLine); _writer.trackSymbol = trackSymbol; _writer.writeKeyword = _writer.write; _writer.writeOperator = _writer.write; @@ -17590,25 +18120,51 @@ var ts; increaseIndent = newWriter.increaseIndent; decreaseIndent = newWriter.decreaseIndent; } - function writeAsychronousImportEqualsDeclarations(importEqualsDeclarations) { - var oldWriter = writer; - ts.forEach(importEqualsDeclarations, function (aliasToWrite) { - var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); - if (aliasEmitInfo) { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); + function writeAsynchronousModuleElements(nodes) { + var _oldWriter = writer; + ts.forEach(nodes, function (declaration) { + var nodeToCheck; + if (declaration.kind === 195) { + nodeToCheck = declaration.parent.parent; + } + else if (declaration.kind === 209 || declaration.kind === 210 || declaration.kind === 207) { + ts.Debug.fail("We should be getting ImportDeclaration instead to write"); + } + else { + nodeToCheck = declaration; + } + var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + } + if (moduleElementEmitInfo) { + if (moduleElementEmitInfo.node.kind === 206) { + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + if (nodeToCheck.kind === 202) { + ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === 202) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); } - writeImportEqualsDeclaration(aliasToWrite); - aliasEmitInfo.asynchronousOutput = writer.getText(); } }); - setWriter(oldWriter); + setWriter(_oldWriter); } function handleSymbolAccessibilityError(symbolAccesibilityResult) { if (symbolAccesibilityResult.accessibility === 0) { if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportEqualsDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); } } else { @@ -17653,25 +18209,27 @@ var ts; emit(node); } } - function emitSeparatedList(nodes, separator, eachNodeEmitFn) { + function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var node = nodes[_i]; - if (currentWriterPos !== writer.getTextPos()) { - write(separator); + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); } } - function emitCommaList(nodes, eachNodeEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn); + function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); } function writeJsDocComments(declaration) { if (declaration) { var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -17680,44 +18238,44 @@ var ts; } function emitType(type) { switch (type.kind) { - case 111: - case 120: - case 118: case 112: case 121: - case 98: + case 119: + case 113: + case 122: + case 99: case 8: return writeTextOfNode(currentSourceFile, type); - case 139: - return emitTypeReference(type); - case 142: - return emitTypeQuery(type); - case 144: - return emitArrayType(type); - case 145: - return emitTupleType(type); - case 146: - return emitUnionType(type); - case 147: - return emitParenType(type); - case 140: case 141: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 144: + return emitTypeQuery(type); + case 146: + return emitArrayType(type); + case 147: + return emitTupleType(type); + case 148: + return emitUnionType(type); + case 149: + return emitParenType(type); + case 142: case 143: + return emitSignatureDeclarationWithJsDocComments(type); + case 145: return emitTypeLiteral(type); - case 64: + case 65: return emitEntityName(type); - case 125: + case 126: return emitEntityName(type); default: ts.Debug.fail("Unknown type annotation: " + type.kind); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 203 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 205 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { - if (entityName.kind === 64) { + if (entityName.kind === 65) { writeTextOfNode(currentSourceFile, entityName); } else { @@ -17775,16 +18333,100 @@ var ts; } function emitExportAssignment(node) { write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); + if (node.expression.kind === 65) { + writeTextOfNode(currentSourceFile, node.expression); + } + else { + write(": "); + if (node.type) { + emitType(node.type); + } + else { + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + } + } write(";"); writeLine(); + if (node.expression.kind === 65) { + var nodes = resolver.collectLinkedAliases(node.expression); + writeAsynchronousModuleElements(nodes); + } + function getDefaultExportAccessibilityDiagnostic(diagnostic) { + return { + diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + function isModuleElementVisible(node) { + return resolver.isDeclarationVisible(node); + } + function emitModuleElement(node, isModuleElementVisible) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + else if (node.kind === 205 || + (node.parent.kind === 224 && ts.isExternalModule(currentSourceFile))) { + var isVisible; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 224) { + asynchronousSubModuleDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + else { + if (node.kind === 206) { + var importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + } + } + function writeModuleElement(node) { + switch (node.kind) { + case 197: + return writeFunctionDeclaration(node); + case 177: + return writeVariableStatement(node); + case 199: + return writeInterfaceDeclaration(node); + case 198: + return writeClassDeclaration(node); + case 200: + return writeTypeAliasDeclaration(node); + case 201: + return writeEnumDeclaration(node); + case 202: + return writeModuleDeclaration(node); + case 205: + return writeImportEqualsDeclaration(node); + case 206: + return writeImportDeclaration(node); + default: + ts.Debug.fail("Unknown symbol kind"); + } } function emitModuleElementDeclarationFlags(node) { if (node.parent === currentSourceFile) { if (node.flags & 1) { write("export "); } - if (node.kind !== 197) { + if (node.flags & 256) { + write("default "); + } + else if (node.kind !== 199) { write("declare "); } } @@ -17800,18 +18442,6 @@ var ts; write("static "); } } - function emitImportEqualsDeclaration(node) { - var nodeEmitInfo = { - declaration: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - hasWritten: resolver.isDeclarationVisible(node) - }; - aliasDeclarationEmitInfo.push(nodeEmitInfo); - if (nodeEmitInfo.hasWritten) { - writeImportEqualsDeclaration(node); - } - } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); if (node.flags & 1) { @@ -17838,40 +18468,110 @@ var ts; }; } } - function emitModuleDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("module "); - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 201) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); + function isVisibleNamedBinding(namedBindings) { + if (namedBindings) { + if (namedBindings.kind === 208) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; } } - function emitTypeAliasDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); + function writeImportDeclaration(node) { + if (!node.importClause && !(node.flags & 1)) { + return; } + emitJsDocComments(node); + if (node.flags & 1) { + write("export "); + } + write("import "); + if (node.importClause) { + var currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + write(", "); + } + if (node.importClause.namedBindings.kind === 208) { + write("* as "); + writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); + } + else { + write("{ "); + emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + function emitImportOrExportSpecifier(node) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + function emitExportSpecifier(node) { + emitImportOrExportSpecifier(node); + var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + writeAsynchronousModuleElements(nodes); + } + function emitExportDeclaration(node) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + function writeModuleDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("module "); + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== 203) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeTypeAliasDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -17880,23 +18580,21 @@ var ts; }; } } - function emitEnumDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); + function writeEnumDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isConst(node)) { + write("const "); } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); } function emitEnumMemberDeclaration(node) { emitJsDocComments(node); @@ -17910,7 +18608,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 132 && (node.parent.flags & 32); + return node.parent.kind === 134 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -17920,15 +18618,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 140 || - node.parent.kind === 141 || - (node.parent.parent && node.parent.parent.kind === 143)) { - ts.Debug.assert(node.parent.kind === 132 || - node.parent.kind === 131 || - node.parent.kind === 140 || - node.parent.kind === 141 || - node.parent.kind === 136 || - node.parent.kind === 137); + if (node.parent.kind === 142 || + node.parent.kind === 143 || + (node.parent.parent && node.parent.parent.kind === 145)) { + ts.Debug.assert(node.parent.kind === 134 || + node.parent.kind === 133 || + node.parent.kind === 142 || + node.parent.kind === 143 || + node.parent.kind === 138 || + node.parent.kind === 139); emitType(node.constraint); } else { @@ -17938,31 +18636,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 196: + case 198: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 197: + case 199: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 137: + case 139: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: + case 138: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 132: - case 131: + case 134: + case 133: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 196) { + else if (node.parent.parent.kind === 198) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 195: + case 197: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -17990,7 +18688,7 @@ var ts; emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 196) { + if (node.parent.parent.kind === 198) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -18006,7 +18704,7 @@ var ts; } } } - function emitClassDeclaration(node) { + function writeClassDeclaration(node) { function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { @@ -18016,49 +18714,45 @@ var ts; }); } } - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassBaseTypeNode(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); - } - emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("class "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); } + emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(ts.getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; } - function emitInterfaceDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } + function writeInterfaceDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; } function emitPropertyDeclaration(node) { if (ts.hasDynamicName(node)) { @@ -18071,54 +18765,83 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 193 || resolver.isDeclarationVisible(node)) { - writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 130 || node.kind === 129) && ts.hasQuestionToken(node)) { - write("?"); + if (node.kind !== 195 || resolver.isDeclarationVisible(node)) { + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); } - if ((node.kind === 130 || node.kind === 129) && node.parent.kind === 143) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + else { + writeTextOfNode(currentSourceFile, node.name); + if ((node.kind === 132 || node.kind === 131) && ts.hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === 132 || node.kind === 131) && node.parent.kind === 145) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & 32)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 193) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + if (node.kind === 195) { + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 130 || node.kind === 129) { + else if (node.kind === 132 || node.kind === 131) { if (node.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 196) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + else if (node.parent.kind === 198) { + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, typeName: node.name } : undefined; } + function emitBindingPattern(bindingPattern) { + emitCommaList(bindingPattern.elements, emitBindingElement); + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + } + } + } } function emitTypeOfVariableDeclarationFromTypeLiteral(node) { if (node.type) { @@ -18126,30 +18849,30 @@ var ts; emitType(node.type); } } - function emitVariableStatement(node) { - var hasDeclarationWithEmit = ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - if (hasDeclarationWithEmit) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node.declarationList)) { - write("let "); - } - else if (ts.isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration); - write(";"); - writeLine(); + function isVariableStatementVisible(node) { + return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + } + function writeVariableStatement(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isLet(node.declarationList)) { + write("let "); } + else if (ts.isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); } function emitAccessorDeclaration(node) { if (ts.hasDynamicName(node)) { return; } - var accessors = getAllAccessorDeclarations(node.parent.members, node); + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); var accessorWithTypeAnnotation; if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); @@ -18160,7 +18883,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 134 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 136 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -18173,7 +18896,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 134 + return accessor.kind === 136 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -18182,7 +18905,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 135) { + if (accessorWithTypeAnnotation.kind === 137) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -18222,24 +18945,23 @@ var ts; } } } - function emitFunctionDeclaration(node) { + function writeFunctionDeclaration(node) { if (ts.hasDynamicName(node)) { return; } - if ((node.kind !== 195 || resolver.isDeclarationVisible(node)) && - !resolver.isImplementationOfOverload(node)) { + if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 195) { + if (node.kind === 197) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 132) { + else if (node.kind === 134) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 195) { + if (node.kind === 197) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 133) { + else if (node.kind === 135) { write("constructor"); } else { @@ -18256,11 +18978,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 137 || node.kind === 141) { + if (node.kind === 139 || node.kind === 143) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 138) { + if (node.kind === 140) { write("["); } else { @@ -18269,20 +18991,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 138) { + if (node.kind === 140) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 140 || node.kind === 141; - if (isFunctionTypeOrConstructorType || node.parent.kind === 143) { + var isFunctionTypeOrConstructorType = node.kind === 142 || node.kind === 143; + if (isFunctionTypeOrConstructorType || node.parent.kind === 145) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 133 && !(node.flags & 32)) { + else if (node.kind !== 135 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -18293,23 +19015,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 137: + case 139: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 136: + case 138: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 138: + case 140: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 132: - case 131: + case 134: + case 133: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -18317,7 +19039,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -18330,7 +19052,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 195: + case 197: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -18362,9 +19084,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 140 || - node.parent.kind === 141 || - node.parent.parent.kind === 143) { + if (node.parent.kind === 142 || + node.parent.kind === 143 || + node.parent.parent.kind === 145) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -18373,25 +19095,25 @@ var ts; function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 133: + case 135: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; - case 137: + case 139: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: + case 138: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 132: - case 131: + case 134: + case 133: if (node.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -18399,7 +19121,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 196) { + else if (node.parent.parent.kind === 198) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -18412,7 +19134,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 195: + case 197: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -18431,60 +19153,81 @@ var ts; } function emitNode(node) { switch (node.kind) { + case 197: + case 202: + case 205: + case 199: + case 198: + case 200: + case 201: + return emitModuleElement(node, isModuleElementVisible(node)); + case 177: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 206: + return emitModuleElement(node, !node.importClause); + case 212: + return emitExportDeclaration(node); + case 135: + case 134: case 133: - case 195: + return writeFunctionDeclaration(node); + case 139: + case 138: + case 140: + return emitSignatureDeclarationWithJsDocComments(node); + case 136: + case 137: + return emitAccessorDeclaration(node); case 132: case 131: - return emitFunctionDeclaration(node); - case 137: - case 136: - case 138: - return emitSignatureDeclarationWithJsDocComments(node); - case 134: - case 135: - return emitAccessorDeclaration(node); - case 175: - return emitVariableStatement(node); - case 130: - case 129: return emitPropertyDeclaration(node); - case 197: - return emitInterfaceDeclaration(node); - case 196: - return emitClassDeclaration(node); - case 198: - return emitTypeAliasDeclaration(node); - case 220: + case 223: return emitEnumMemberDeclaration(node); - case 199: - return emitEnumDeclaration(node); - case 200: - return emitModuleDeclaration(node); - case 203: - return emitImportEqualsDeclaration(node); - case 209: + case 211: return emitExportAssignment(node); - case 221: + case 224: return emitSourceFile(node); } } function writeReferencePath(referencedFile) { var declFileName = referencedFile.flags & 2048 ? referencedFile.fileName - : shouldEmitToOwnFile(referencedFile, compilerOptions) - ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") + : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) + ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } } - function getDeclarationDiagnostics(host, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; + function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { + var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + if (!emitDeclarationResult.reportedDeclarationError) { + var declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { + var appliedSyncOutputPos = 0; + var _declarationOutput = ""; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + _declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + _declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + _declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return _declarationOutput; + } } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + ts.writeDeclarationFile = writeDeclarationFile; +})(ts || (ts = {})); +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; @@ -18493,8 +19236,8 @@ var ts; var newLine = host.getNewLine(); if (targetSourceFile === undefined) { ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, ".js"); + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -18503,8 +19246,8 @@ var ts; } } else { - if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -18517,8 +19260,26 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } function emitJavaScript(jsFilePath, root) { - var writer = createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var write = writer.write; var writeTextOfNode = writer.writeTextOfNode; var writeLine = writer.writeLine; @@ -18526,26 +19287,23 @@ var ts; var decreaseIndent = writer.decreaseIndent; var preserveNewLines = compilerOptions.preserveNewLines || false; var currentSourceFile; - var lastFrame; - var currentScopeNames; - var generatedBlockScopeNames; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var blockScopedVariableToGeneratedName; + var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; - var tempCount = 0; + var decorateEmitted = false; + var tempFlags = 0; var tempVariables; var tempParameters; var externalImports; var exportSpecifiers; - var exportDefault; + var exportEquals; + var hasExportStars; var writeEmittedFiles = writeJavaScriptFile; - var emitLeadingComments = compilerOptions.removeComments ? function (node) { } : emitLeadingDeclarationComments; - var emitTrailingComments = compilerOptions.removeComments ? function (node) { } : emitTrailingDeclarationComments; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfLocalPosition; var detachedCommentsInfo; - var emitDetachedComments = compilerOptions.removeComments ? function (node) { } : emitDetachedCommentsAtPosition; - var writeComment = writeCommentRange; - var emitNodeWithoutSourceMap = compilerOptions.removeComments ? emitNodeWithoutSourceMapWithoutComments : emitNodeWithoutSourceMapWithComments; + var writeComment = ts.writeCommentRange; var emit = emitNodeWithoutSourceMap; - var emitWithoutComments = emitNodeWithoutSourceMapWithoutComments; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; @@ -18572,55 +19330,108 @@ var ts; currentSourceFile = sourceFile; emit(sourceFile); } - function enterNameScope() { - var names = currentScopeNames; - currentScopeNames = undefined; - if (names) { - lastFrame = { names: names, previous: lastFrame }; - return true; - } - return false; + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); } - function exitNameScope(popFrame) { - if (popFrame) { - currentScopeNames = lastFrame.names; - lastFrame = lastFrame.previous; - } - else { - currentScopeNames = undefined; - } - } - function generateUniqueNameForLocation(location, baseName) { - var _name; - if (!isExistingName(location, baseName)) { - _name = baseName; - } - else { - _name = ts.generateUniqueName(baseName, function (n) { return isExistingName(location, n); }); - } - return recordNameInCurrentScope(_name); - } - function recordNameInCurrentScope(name) { - if (!currentScopeNames) { - currentScopeNames = {}; - } - return currentScopeNames[name] = name; - } - function isExistingName(location, name) { - if (!resolver.isUnknownIdentifier(location, name)) { - return true; - } - if (currentScopeNames && ts.hasProperty(currentScopeNames, name)) { - return true; - } - var frame = lastFrame; - while (frame) { - if (ts.hasProperty(frame.names, name)) { - return true; + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { + tempFlags |= flags; + return name; } - frame = frame.previous; } - return false; + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var _name = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(_name)) { + return _name; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function assignGeneratedName(node, name) { + nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); + } + function generateNameForFunctionOrClassDeclaration(node) { + if (!node.name) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForModuleOrEnum(node) { + if (node.name.kind === 65) { + var _name = node.name.text; + assignGeneratedName(node, isUniqueLocalName(_name, node) ? _name : makeUniqueName(_name)); + } + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 8 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + assignGeneratedName(node, makeUniqueName(baseName)); + } + function generateNameForImportDeclaration(node) { + if (node.importClause) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportDeclaration(node) { + if (node.moduleSpecifier) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportAssignment(node) { + if (node.expression && node.expression.kind !== 65) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForNode(node) { + switch (node.kind) { + case 197: + case 198: + generateNameForFunctionOrClassDeclaration(node); + break; + case 202: + generateNameForModuleOrEnum(node); + generateNameForNode(node.body); + break; + case 201: + generateNameForModuleOrEnum(node); + break; + case 206: + generateNameForImportDeclaration(node); + break; + case 212: + generateNameForExportDeclaration(node); + break; + case 211: + generateNameForExportAssignment(node); + break; + } + } + function getGeneratedNameForNode(node) { + var nodeId = ts.getNodeId(node); + if (!nodeToGeneratedName[nodeId]) { + generateNameForNode(node); + } + return nodeToGeneratedName[nodeId]; } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -18747,7 +19558,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var _name = node.name; - if (!_name || _name.kind !== 126) { + if (!_name || _name.kind !== 127) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -18764,18 +19575,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 195 || - node.kind === 160 || - node.kind === 132 || - node.kind === 131 || + else if (node.kind === 197 || + node.kind === 162 || node.kind === 134 || - node.kind === 135 || - node.kind === 200 || - node.kind === 196 || - node.kind === 199) { + node.kind === 133 || + node.kind === 136 || + node.kind === 137 || + node.kind === 202 || + node.kind === 198 || + node.kind === 201) { if (node.name) { var _name = node.name; - scopeName = _name.kind === 126 + scopeName = _name.kind === 127 ? ts.getTextOfNode(_name) : node.name.text; } @@ -18791,7 +19602,7 @@ var ts; ; function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { recordSourceMapSpan(comment.pos); - writeCommentRange(currentSourceFile, writer, comment, newLine); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { @@ -18819,7 +19630,7 @@ var ts; } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { encodeLastRecordedSourceMapSpan(); - writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); sourceMapDataList.push(sourceMapData); writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); } @@ -18842,7 +19653,7 @@ var ts; if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); if (root) { - sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, host, sourceMapDir)); + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -18855,32 +19666,24 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node) { + function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); + return emitNodeWithoutSourceMap(node, false); } - if (node.kind != 221) { + if (node.kind != 224) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, false); } } } - function emitNodeWithSourceMapWithoutComments(node) { - if (node) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMapWithoutComments(node); - recordEmitNodeEndSpan(node); - } - } writeEmittedFiles = writeJavaScriptAndSourceMapFile; emit = emitNodeWithSourceMap; - emitWithoutComments = emitNodeWithSourceMapWithoutComments; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -18889,24 +19692,11 @@ var ts; writeComment = writeCommentRangeWithMap; } function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } - function createTempVariable(location, preferredName) { - for (var name = preferredName; !name || isExistingName(location, name); tempCount++) { - var char = 97 + tempCount; - if (char === 105 || char === 110) { - continue; - } - if (tempCount < 26) { - name = "_" + String.fromCharCode(char); - } - else { - name = "_" + (tempCount - 26); - } - } - recordNameInCurrentScope(name); - var result = ts.createSynthesizedNode(64); - result.text = name; + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(65); + result.text = makeTempVariableName(flags); return result; } function recordTempDeclaration(name) { @@ -18915,8 +19705,8 @@ var ts; } tempVariables.push(name); } - function createAndRecordTempVariable(location, preferredName) { - var temp = createTempVariable(location, preferredName); + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); recordTempDeclaration(temp); return temp; } @@ -19108,7 +19898,7 @@ var ts; write("]"); } function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(node); + var tempVariable = createAndRecordTempVariable(0); write("("); emit(tempVariable); write(" = "); @@ -19121,10 +19911,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 169) { + if (node.template.kind === 171) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 167 + var needsParens = templateSpan.expression.kind === 169 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -19148,7 +19938,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 159 + var needsParens = templateSpan.expression.kind !== 161 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -19168,11 +19958,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 155: - case 156: - return parent.expression === template; case 157: + case 158: + return parent.expression === template; case 159: + case 161: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -19180,7 +19970,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 167: + case 169: switch (expression.operatorToken.kind) { case 35: case 36: @@ -19192,7 +19982,7 @@ var ts; default: return -1; } - case 168: + case 170: return -1; default: return 1; @@ -19204,11 +19994,27 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 150); + ts.Debug.assert(node.kind !== 152); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 126) { + else if (node.kind === 127) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[node.id]; + if (generatedName) { + write(generatedName); + return; + } + var generatedVariable = createTempVariable(0); + generatedName = generatedVariable.text; + recordTempDeclaration(generatedVariable); + computedPropertyNamesToGeneratedNames[node.id] = generatedName; + write(generatedName); + write(" = "); + } emit(node.expression); } else { @@ -19225,36 +20031,41 @@ var ts; function isNotExpressionIdentifier(node) { var _parent = node.parent; switch (_parent.kind) { - case 128: - case 193: - case 150: - case 130: case 129: - case 218: - case 219: - case 220: + case 195: + case 152: case 132: case 131: - case 195: + case 221: + case 222: + case 223: case 134: - case 135: - case 160: - case 196: + case 133: case 197: + case 136: + case 137: + case 162: + case 198: case 199: - case 200: - case 203: + case 201: + case 202: + case 205: + case 207: + case 208: return _parent.name === node; - case 185: - case 184: - case 209: + case 210: + case 214: + return _parent.name === node || _parent.propertyName === node; + case 187: + case 186: + case 211: return false; - case 189: + case 191: return node.parent.label === node; } } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node); + var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); if (substitution) { write(substitution); } @@ -19262,15 +20073,21 @@ var ts; writeTextOfNode(currentSourceFile, node); } } - function getBlockScopedVariableId(node) { - return !ts.nodeIsSynthesized(node) && resolver.getBlockScopedVariableId(node); + function getGeneratedNameForIdentifier(node) { + if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { + return undefined; + } + var variableId = resolver.getBlockScopedVariableId(node); + if (variableId === undefined) { + return undefined; + } + return blockScopedVariableToGeneratedName[variableId]; } - function emitIdentifier(node) { - var variableId = getBlockScopedVariableId(node); - if (variableId !== undefined && generatedBlockScopeNames) { - var text = generatedBlockScopeNames[variableId]; - if (text) { - write(text); + function emitIdentifier(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers) { + var generatedName = getGeneratedNameForIdentifier(node); + if (generatedName) { + write(generatedName); return; } } @@ -19293,15 +20110,17 @@ var ts; } } function emitSuper(node) { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 16) { - write("_super.prototype"); - } - else if (flags & 32) { - write("_super"); + if (languageVersion >= 2) { + write("super"); } else { - write("super"); + var flags = resolver.getNodeCheckFlags(node); + if (flags & 16) { + write("_super.prototype"); + } + else { + write("_super"); + } } } function emitObjectBindingPattern(node) { @@ -19318,7 +20137,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName); + emit(node.propertyName, false); write(": "); } if (node.dotDotDotToken) { @@ -19338,12 +20157,12 @@ var ts; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 64: - case 151: + case 65: case 153: - case 154: case 155: - case 159: + case 156: + case 157: + case 161: return false; } return true; @@ -19360,14 +20179,14 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 171) { + if (e.kind === 173) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { var i = pos; - while (i < _length && elements[i].kind !== 171) { + while (i < _length && elements[i].kind !== 173) { i++; } write("["); @@ -19388,7 +20207,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 171; + return node.kind === 173; } function emitArrayLiteral(node) { var elements = node.elements; @@ -19409,11 +20228,11 @@ var ts; return emit(parenthesizedObjectLiteral); } function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral, firstComputedPropertyIndex) { - var tempVar = createAndRecordTempVariable(originalObjectLiteral); - var initialObjectLiteral = ts.createSynthesizedNode(152); + var tempVar = createAndRecordTempVariable(0); + var initialObjectLiteral = ts.createSynthesizedNode(154); initialObjectLiteral.properties = originalObjectLiteral.properties.slice(0, firstComputedPropertyIndex); initialObjectLiteral.flags |= 512; - var propertyPatches = createBinaryExpression(tempVar, 52, initialObjectLiteral); + var propertyPatches = createBinaryExpression(tempVar, 53, initialObjectLiteral); ts.forEach(originalObjectLiteral.properties, function (property) { var patchedProperty = tryCreatePatchingPropertyAssignment(originalObjectLiteral, tempVar, property); if (patchedProperty) { @@ -19431,23 +20250,23 @@ var ts; function tryCreatePatchingPropertyAssignment(objectLiteral, tempVar, property) { var leftHandSide = createMemberAccessForPropertyName(tempVar, property.name); var maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property); - return maybeRightHandSide && createBinaryExpression(leftHandSide, 52, maybeRightHandSide, true); + return maybeRightHandSide && createBinaryExpression(leftHandSide, 53, maybeRightHandSide, true); } function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property) { switch (property.kind) { - case 218: + case 221: return property.initializer; - case 219: - return createIdentifier(resolver.getExpressionNameSubstitution(property.name)); - case 132: - return createFunctionExpression(property.parameters, property.body); + case 222: + return createIdentifier(resolver.getExpressionNameSubstitution(property.name, getGeneratedNameForNode)); case 134: - case 135: - var _a = getAllAccessorDeclarations(objectLiteral.properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + return createFunctionExpression(property.parameters, property.body); + case 136: + case 137: + var _a = ts.getAllAccessorDeclarations(objectLiteral.properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (firstAccessor !== property) { return undefined; } - var propertyDescriptor = ts.createSynthesizedNode(152); + var propertyDescriptor = ts.createSynthesizedNode(154); var descriptorProperties = []; if (getAccessor) { var _getProperty = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body)); @@ -19457,7 +20276,7 @@ var ts; var setProperty = createPropertyAssignment(createIdentifier("set"), createFunctionExpression(setAccessor.parameters, setAccessor.body)); descriptorProperties.push(setProperty); } - var trueExpr = ts.createSynthesizedNode(94); + var trueExpr = ts.createSynthesizedNode(95); var enumerableTrue = createPropertyAssignment(createIdentifier("enumerable"), trueExpr); descriptorProperties.push(enumerableTrue); var configurableTrue = createPropertyAssignment(createIdentifier("configurable"), trueExpr); @@ -19470,7 +20289,7 @@ var ts; } } function createParenthesizedExpression(expression) { - var result = ts.createSynthesizedNode(159); + var result = ts.createSynthesizedNode(161); result.expression = expression; return result; } @@ -19485,25 +20304,25 @@ var ts; return result; } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(167, startsOnNewLine); + var result = ts.createSynthesizedNode(169, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createExpressionStatement(expression) { - var result = ts.createSynthesizedNode(177); + var result = ts.createSynthesizedNode(179); result.expression = expression; return result; } function createMemberAccessForPropertyName(expression, memberName) { - if (memberName.kind === 64) { + if (memberName.kind === 65) { return createPropertyAccessExpression(expression, memberName); } else if (memberName.kind === 8 || memberName.kind === 7) { return createElementAccessExpression(expression, memberName); } - else if (memberName.kind === 126) { + else if (memberName.kind === 127) { return createElementAccessExpression(expression, memberName.expression); } else { @@ -19511,37 +20330,37 @@ var ts; } } function createPropertyAssignment(name, initializer) { - var result = ts.createSynthesizedNode(218); + var result = ts.createSynthesizedNode(221); result.name = name; result.initializer = initializer; return result; } function createFunctionExpression(parameters, body) { - var result = ts.createSynthesizedNode(160); + var result = ts.createSynthesizedNode(162); result.parameters = parameters; result.body = body; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(153); + var result = ts.createSynthesizedNode(155); result.expression = expression; result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(154); + var result = ts.createSynthesizedNode(156); result.expression = expression; result.argumentExpression = argumentExpression; return result; } function createIdentifier(name, startsOnNewLine) { - var result = ts.createSynthesizedNode(64, startsOnNewLine); + var result = ts.createSynthesizedNode(65, startsOnNewLine); result.text = name; return result; } function createCallExpression(invokedExpression, arguments) { - var result = ts.createSynthesizedNode(155); + var result = ts.createSynthesizedNode(157); result.expression = invokedExpression; result.arguments = arguments; return result; @@ -19552,7 +20371,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 126) { + if (properties[i].name.kind === 127) { numInitialNonComputedProperties = i; break; } @@ -19571,24 +20390,34 @@ var ts; } function emitComputedPropertyName(node) { write("["); - emit(node.expression); + emitExpressionForPropertyName(node); write("]"); } function emitMethod(node) { - emit(node.name); + emit(node.name, false); if (languageVersion < 2) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name); + emit(node.name, false); write(": "); emit(node.initializer); } function emitShorthandPropertyAssignment(node) { - emit(node.name); - if (languageVersion < 2 || resolver.getExpressionNameSubstitution(node.name)) { + emit(node.name, false); + if (languageVersion < 2) { + write(": "); + var generatedName = getGeneratedNameForIdentifier(node.name); + if (generatedName) { + write(generatedName); + } + else { + emitExpressionIdentifier(node.name); + } + } + else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { write(": "); emitExpressionIdentifier(node.name); } @@ -19598,7 +20427,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 153 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 155 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -19628,7 +20457,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); + emit(node.name, false); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -19646,20 +20475,20 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 171; }); + return ts.forEach(elements, function (e) { return e.kind === 173; }); } function skipParentheses(node) { - while (node.kind === 159 || node.kind === 158) { + while (node.kind === 161 || node.kind === 160) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 64 || node.kind === 92 || node.kind === 90) { + if (node.kind === 65 || node.kind === 93 || node.kind === 91) { emit(node); return node; } - var temp = createAndRecordTempVariable(node); + var temp = createAndRecordTempVariable(0); write("("); emit(temp); write(" = "); @@ -19670,18 +20499,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 153) { + if (expr.kind === 155) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 154) { + else if (expr.kind === 156) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 90) { + else if (expr.kind === 91) { target = expr; write("_super"); } @@ -19690,7 +20519,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 90) { + if (target.kind === 91) { emitThis(target); } else { @@ -19710,15 +20539,15 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 90) { - write("_super"); + if (node.expression.kind === 91) { + emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 153 && node.expression.expression.kind === 90; + superCall = node.expression.kind === 155 && node.expression.expression.kind === 91; } - if (superCall) { + if (superCall && languageVersion < 2) { write(".call("); emitThis(node.expression); if (node.arguments.length) { @@ -19743,7 +20572,7 @@ var ts; } } function emitTaggedTemplateExpression(node) { - if (compilerOptions.target >= 2) { + if (languageVersion >= 2) { emit(node.tag); write(" "); emit(node.template); @@ -19753,20 +20582,20 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 161) { - if (node.expression.kind === 158) { + if (!node.parent || node.parent.kind !== 163) { + if (node.expression.kind === 160) { var operand = node.expression.expression; - while (operand.kind == 158) { + while (operand.kind == 160) { operand = operand.expression; } - if (operand.kind !== 165 && - operand.kind !== 164 && - operand.kind !== 163 && - operand.kind !== 162 && + if (operand.kind !== 167 && operand.kind !== 166 && - operand.kind !== 156 && - !(operand.kind === 155 && node.parent.kind === 156) && - !(operand.kind === 160 && node.parent.kind === 155)) { + operand.kind !== 165 && + operand.kind !== 164 && + operand.kind !== 168 && + operand.kind !== 158 && + !(operand.kind === 157 && node.parent.kind === 158) && + !(operand.kind === 162 && node.parent.kind === 157)) { emit(operand); return; } @@ -19777,23 +20606,23 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(73)); + write(ts.tokenToString(74)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(96)); + write(ts.tokenToString(97)); write(" "); emit(node.expression); } function emitPrefixUnaryExpression(node) { write(ts.tokenToString(node.operator)); - if (node.operand.kind === 165) { + if (node.operand.kind === 167) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -19809,9 +20638,9 @@ var ts; write(ts.tokenToString(node.operator)); } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 52 && - (node.left.kind === 152 || node.left.kind === 151)) { - emitDestructuring(node, node.parent.kind === 177); + if (languageVersion < 2 && node.operatorToken.kind === 53 && + (node.left.kind === 154 || node.left.kind === 153)) { + emitDestructuring(node, node.parent.kind === 179); } else { emit(node.left); @@ -19847,7 +20676,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 174) { + if (node && node.kind === 176) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -19862,12 +20691,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 201) { - ts.Debug.assert(node.parent.kind === 200); + if (node.kind === 203) { + ts.Debug.assert(node.parent.kind === 202); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 201) { + if (node.kind === 203) { emitTempDeclarations(true); } decreaseIndent(); @@ -19876,7 +20705,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 174) { + if (node.kind === 176) { write(" "); emit(node); } @@ -19888,11 +20717,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 161); + emitParenthesizedIf(node.expression, node.expression.kind === 163); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); endPos = emitToken(16, endPos); emit(node.expression); @@ -19900,8 +20729,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(75, node.thenStatement.end); - if (node.elseStatement.kind === 178) { + emitToken(76, node.thenStatement.end); + if (node.elseStatement.kind === 180) { write(" "); emit(node.elseStatement); } @@ -19913,7 +20742,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 174) { + if (node.statement.kind === 176) { write(" "); } else { @@ -19930,13 +20759,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitStartOfVariableDeclarationList(decl, startPos) { - var tokenKind = 97; + var tokenKind = 98; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 104; + tokenKind = 105; } else if (ts.isConst(decl)) { - tokenKind = 69; + tokenKind = 70; } } if (startPos !== undefined) { @@ -19944,20 +20773,20 @@ var ts; } else { switch (tokenKind) { - case 97: + case 98: return write("var "); - case 104: + case 105: return write("let "); - case 69: + case 70: return write("const "); } } } function emitForStatement(node) { - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 194) { + if (node.initializer && node.initializer.kind === 196) { var variableDeclarationList = node.initializer; var declarations = variableDeclarationList.declarations; emitStartOfVariableDeclarationList(declarations[0], endPos); @@ -19975,13 +20804,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 183) { + if (languageVersion < 2 && node.kind === 185) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { var decl = variableDeclarationList.declarations[0]; @@ -19993,7 +20822,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 182) { + if (node.kind === 184) { write(" in "); } else { @@ -20004,13 +20833,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 64; - var counter = createTempVariable(node, "_i"); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node); - var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, "_n") : undefined; + var rhsIsIdentifier = node.expression.kind === 65; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(536870912) : undefined; emitStart(node.expression); write("var "); emitNodeWithoutSourceMap(counter); @@ -20054,7 +20883,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -20069,14 +20898,14 @@ var ts; } } else { - emitNodeWithoutSourceMap(createTempVariable(node)); + emitNodeWithoutSourceMap(createTempVariable(0)); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 52, rhsIterationValue, false); - if (node.initializer.kind === 151 || node.initializer.kind === 152) { + var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); + if (node.initializer.kind === 153 || node.initializer.kind === 154) { emitDestructuring(assignmentExpression, true, undefined, node); } else { @@ -20085,7 +20914,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 174) { + if (node.statement.kind === 176) { emitLines(node.statement.statements); } else { @@ -20097,12 +20926,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 185 ? 65 : 70, node.pos); + emitToken(node.kind === 187 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(89, node.pos); + emitToken(90, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -20113,7 +20942,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(91, node.pos); + var endPos = emitToken(92, node.pos); write(" "); emitToken(16, endPos); emit(node.expression); @@ -20130,19 +20959,19 @@ var ts; emitToken(15, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function nodeEndPositionsAreOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, node2.end); + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); } function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 214) { + if (node.kind === 217) { write("case "); emit(node.expression); write(":"); @@ -20177,7 +21006,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(67, node.pos); + var endPos = emitToken(68, node.pos); write(" "); emitToken(16, endPos); emit(node.variableDeclaration); @@ -20186,7 +21015,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(71, node.pos); + emitToken(72, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -20197,18 +21026,24 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 200); + } while (node && node.kind !== 202); return node; } function emitContainingModuleName(node) { var container = getContainingModule(node); - write(container ? resolver.getGeneratedNameForNode(container) : "exports"); + write(container ? getGeneratedNameForNode(container) : "exports"); } function emitModuleMemberName(node) { emitStart(node.name); if (ts.getCombinedNodeFlags(node) & 1) { - emitContainingModuleName(node); - write("."); + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (languageVersion < 2) { + write("exports."); + } } emitNodeWithoutSourceMap(node.name); emitEnd(node.name); @@ -20216,13 +21051,30 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(166); result.expression = zero; return result; } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (node.name) { + emitModuleMemberName(node); + } + else { + write("exports.default"); + } + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + } function emitExportMemberAssignments(name) { - if (!exportDefault && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - ts.forEach(exportSpecifiers[name.text], function (specifier) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _i = 0, _a = exportSpecifiers[name.text], _n = _a.length; _i < _n; _i++) { + var specifier = _a[_i]; writeLine(); emitStart(specifier.name); emitContainingModuleName(specifier); @@ -20230,15 +21082,15 @@ var ts; emitNodeWithoutSourceMap(specifier.name); emitEnd(specifier.name); write(" = "); - emitNodeWithoutSourceMap(name); + emitExpressionIdentifier(name); write(";"); - }); + } } } function emitDestructuring(root, isAssignmentExpressionStatement, value, lowestNonSynthesizedAncestor) { var emitCount = 0; - var _isDeclaration = (root.kind === 193 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 128; - if (root.kind === 167) { + var _isDeclaration = (root.kind === 195 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 129; + if (root.kind === 169) { emitAssignmentExpression(root); } else { @@ -20250,7 +21102,7 @@ var ts; write(", "); } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === 193 || name.parent.kind === 150)) { + if (name.parent && (name.parent.kind === 195 || name.parent.kind === 152)) { emitModuleMemberName(name.parent); } else { @@ -20260,8 +21112,8 @@ var ts; emit(value); } function ensureIdentifier(expr) { - if (expr.kind !== 64) { - var identifier = createTempVariable(lowestNonSynthesizedAncestor || root); + if (expr.kind !== 65) { + var identifier = createTempVariable(0); if (!_isDeclaration) { recordTempDeclaration(identifier); } @@ -20272,14 +21124,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(167); + var equals = ts.createSynthesizedNode(169); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(168); + var cond = ts.createSynthesizedNode(170); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -20293,21 +21145,21 @@ var ts; return node; } function parenthesizeForAccess(expr) { - if (expr.kind === 64 || expr.kind === 153 || expr.kind === 154) { + if (expr.kind === 65 || expr.kind === 155 || expr.kind === 156) { return expr; } - var node = ts.createSynthesizedNode(159); + var node = ts.createSynthesizedNode(161); node.expression = expr; return node; } function createPropertyAccess(object, propName) { - if (propName.kind !== 64) { + if (propName.kind !== 65) { return createElementAccess(object, propName); } return createPropertyAccessExpression(parenthesizeForAccess(object), propName); } function createElementAccess(object, index) { - var node = ts.createSynthesizedNode(154); + var node = ts.createSynthesizedNode(156); node.expression = parenthesizeForAccess(object); node.argumentExpression = index; return node; @@ -20319,7 +21171,7 @@ var ts; } for (var _i = 0, _n = properties.length; _i < _n; _i++) { var p = properties[_i]; - if (p.kind === 218 || p.kind === 219) { + if (p.kind === 221 || p.kind === 222) { var propName = (p.name); emitDestructuringAssignment(p.initializer || propName, createPropertyAccess(value, propName)); } @@ -20332,8 +21184,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 172) { - if (e.kind !== 171) { + if (e.kind !== 174) { + if (e.kind !== 173) { emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i))); } else { @@ -20347,14 +21199,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 167 && target.operatorToken.kind === 52) { + if (target.kind === 169 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 152) { + if (target.kind === 154) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 151) { + else if (target.kind === 153) { emitArrayLiteralAssignment(target, value); } else { @@ -20368,14 +21220,14 @@ var ts; emitDestructuringAssignment(target, _value); } else { - if (root.parent.kind !== 159) { + if (root.parent.kind !== 161) { write("("); } _value = ensureIdentifier(_value); emitDestructuringAssignment(target, _value); write(", "); emit(_value); - if (root.parent.kind !== 159) { + if (root.parent.kind !== 161) { write(")"); } } @@ -20395,11 +21247,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 148) { + if (pattern.kind === 150) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccess(value, propName)); } - else if (element.kind !== 172) { + else if (element.kind !== 174) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccess(value, createNumericLiteral(i))); } @@ -20436,8 +21288,8 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 182 && - node.parent.parent.kind !== 183) { + node.parent.parent.kind !== 184 && + node.parent.parent.kind !== 185) { initializer = createVoidZero(); } } @@ -20445,8 +21297,11 @@ var ts; } } function emitExportVariableAssignments(node) { + if (node.kind === 174) { + return; + } var _name = node.name; - if (_name.kind === 64) { + if (_name.kind === 65) { emitExportMemberAssignments(_name); } else if (ts.isBindingPattern(_name)) { @@ -20454,7 +21309,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 193 && node.parent.kind !== 150)) { + if (!node.parent || (node.parent.kind !== 195 && node.parent.kind !== 152)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -20462,33 +21317,49 @@ var ts; function renameNonTopLevelLetAndConst(node) { if (languageVersion >= 2 || ts.nodeIsSynthesized(node) || - node.kind !== 64 || - (node.parent.kind !== 193 && node.parent.kind !== 150)) { + node.kind !== 65 || + (node.parent.kind !== 195 && node.parent.kind !== 152)) { return; } var combinedFlags = getCombinedFlagsForIdentifier(node); if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { return; } - var list = ts.getAncestor(node, 194); - if (list.parent.kind === 175 && list.parent.parent.kind === 221) { - return; + var list = ts.getAncestor(node, 196); + if (list.parent.kind === 177) { + var isSourceFileLevelBinding = list.parent.parent.kind === 224; + var isModuleLevelBinding = list.parent.parent.kind === 203; + var isFunctionLevelBinding = list.parent.parent.kind === 176 && ts.isFunctionLike(list.parent.parent.parent); + if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { + return; + } } var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var _parent = blockScopeContainer.kind === 221 + var _parent = blockScopeContainer.kind === 224 ? blockScopeContainer : blockScopeContainer.parent; - var generatedName = generateUniqueNameForLocation(_parent, node.text); - var variableId = resolver.getBlockScopedVariableId(node); - if (!generatedBlockScopeNames) { - generatedBlockScopeNames = []; + if (resolver.resolvesToSomeValue(_parent, node.text)) { + var variableId = resolver.getBlockScopedVariableId(node); + if (!blockScopedVariableToGeneratedName) { + blockScopedVariableToGeneratedName = []; + } + var generatedName = makeUniqueName(node.text); + blockScopedVariableToGeneratedName[variableId] = generatedName; } - generatedBlockScopeNames[variableId] = generatedName; + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + languageVersion >= 2 && + node.parent.kind === 224; } function emitVariableStatement(node) { if (!(node.flags & 1)) { emitStartOfVariableDeclarationList(node.declarationList); } + else if (isES6ExportedDeclaration(node)) { + write("export "); + emitStartOfVariableDeclarationList(node.declarationList); + } emitCommaList(node.declarationList.declarations); write(";"); if (languageVersion < 2 && node.parent === currentSourceFile) { @@ -20498,7 +21369,7 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var _name = createTempVariable(node); + var _name = createTempVariable(0); if (!tempParameters) { tempParameters = []; } @@ -20550,7 +21421,7 @@ var ts; if (languageVersion < 2 && ts.hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; - var tempName = createTempVariable(node, "_i").text; + var tempName = createTempVariable(268435456).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -20585,39 +21456,53 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 134 ? "get " : "set "); - emit(node.name); + write(node.kind === 136 ? "get " : "set "); + emit(node.name, false); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 161 && languageVersion >= 2; + return node.kind === 163 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { emitNodeWithoutSourceMap(node.name); } else { - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 162) { + return !!node.name; + } + else if (node.kind === 197) { + return !!node.name || (languageVersion >= 2 && !(node.flags & 256)); } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 134 && node.kind !== 133) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256) { + write("default "); + } + } write("function "); } - if (node.kind === 195 || (node.kind === 160 && node.name)) { + if (shouldEmitFunctionName(node)) { emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 195 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 197 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 134 && node.kind !== 133) { emitTrailingComments(node); } } @@ -20648,13 +21533,12 @@ var ts; emitSignatureParameters(node); } function emitSignatureAndBody(node) { - var saveTempCount = tempCount; + var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; var saveTempParameters = tempParameters; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; tempParameters = undefined; - var popFrame = enterNameScope(); if (shouldEmitAsArrowFunction(node)) { emitSignatureParametersForArrow(node); write(" =>"); @@ -20665,23 +21549,16 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 174) { + else if (node.body.kind === 176) { emitBlockFunctionBody(node, node.body); } else { emitExpressionFunctionBody(node, node.body); } - if (node.flags & 1 && !(node.flags & 256)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); } - exitNameScope(popFrame); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; } @@ -20697,10 +21574,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 158) { + while (current.kind === 160) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 152); + emitParenthesizedIf(body, current.kind === 154); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -20715,7 +21592,7 @@ var ts; write(" "); emitStart(body); write("return "); - emitWithoutComments(body); + emit(body); emitEnd(body); write(";"); emitTempDeclarations(false); @@ -20726,7 +21603,7 @@ var ts; writeLine(); emitLeadingComments(node.body); write("return "); - emitWithoutComments(node.body); + emit(body); write(";"); emitTrailingComments(node.body); emitTempDeclarations(true); @@ -20772,11 +21649,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 177) { + if (statement && statement.kind === 179) { var expr = statement.expression; - if (expr && expr.kind === 155) { + if (expr && expr.kind === 157) { var func = expr.expression; - if (func && func.kind === 90) { + if (func && func.kind === 91) { return statement; } } @@ -20805,7 +21682,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 126) { + else if (memberName.kind === 127) { emitComputedPropertyName(memberName); } else { @@ -20815,7 +21692,7 @@ var ts; } function emitMemberAssignments(node, staticFlag) { ts.forEach(node.members, function (member) { - if (member.kind === 130 && (member.flags & 128) === staticFlag && member.initializer) { + if (member.kind === 132 && (member.flags & 128) === staticFlag && member.initializer) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -20836,20 +21713,17 @@ var ts; } }); } - function emitMemberFunctions(node) { + function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 132 || node.kind === 131) { + if (member.kind === 134 || node.kind === 133) { if (!member.body) { - return emitPinnedOrTripleSlashComments(member); + return emitOnlyPinnedOrTripleSlashComments(member); } writeLine(); emitLeadingComments(member); emitStart(member); emitStart(member.name); - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); @@ -20860,17 +21734,14 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 134 || member.kind === 135) { - var accessors = getAllAccessorDeclarations(node.members, member); + else if (member.kind === 136 || member.kind === 137) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); emitStart(member); write("Object.defineProperty("); emitStart(member.name); - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); @@ -20910,7 +21781,207 @@ var ts; } }); } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _i = 0, _a = node.members, _n = _a.length; _i < _n; _i++) { + var member = _a[_i]; + if ((member.kind === 134 || node.kind === 133) && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + else if (member.kind === 134 || node.kind === 133 || member.kind === 136 || member.kind === 137) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 136) { + write("get "); + } + else if (member.kind === 137) { + write("set "); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + } + } + function emitConstructor(node, baseTypeNode) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 135 && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + if (member.kind === 132 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeNode) { + write("(...args)"); + } + else { + write("()"); + } + } + } + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeNode) { + var superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeNode); + } + } + emitMemberAssignments(node, 0); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLines(statements); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } function emitClassDeclaration(node) { + if (languageVersion < 2) { + emitClassDeclarationBelowES6(node); + } + else { + emitClassDeclarationForES6AndHigher(node); + } + } + function emitClassDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256) { + write("default "); + } + } + write("class"); + if ((node.name || !(node.flags & 256)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.typeName); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(15, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + if (node.name) { + writeLine(); + write("Object.defineProperty("); + emitDeclarationName(node); + write(", \"name\", { value: \""); + emitDeclarationName(node); + write("\", configurable: true });"); + writeLine(); + } + } + writeLine(); + emitMemberAssignments(node, 128); + emitDecoratorsOfClass(node); + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 256) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassDeclarationBelowES6(node) { write("var "); emitDeclarationName(node); write(" = (function ("); @@ -20919,6 +21990,14 @@ var ts; write("_super"); } write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; increaseIndent(); scopeEmitStart(node); if (baseTypeNode) { @@ -20930,15 +22009,22 @@ var ts; emitEnd(baseTypeNode); } writeLine(); - emitConstructorOfClass(); - emitMemberFunctions(node); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); emitMemberAssignments(node, 128); writeLine(); + emitDecoratorsOfClass(node); + writeLine(); emitToken(15, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); emitToken(15, node.members.end); @@ -20950,94 +22036,147 @@ var ts; } write(");"); emitEnd(node); - if (node.flags & 1 && !(node.flags & 256)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } + emitExportMemberAssignment(node); if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - function emitConstructorOfClass() { - var saveTempCount = tempCount; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempCount = 0; - tempVariables = undefined; - tempParameters = undefined; - var popFrame = enterNameScope(); - ts.forEach(node.members, function (member) { - if (member.kind === 133 && !member.body) { - emitPinnedOrTripleSlashComments(member); - } - }); - var ctor = getFirstConstructorWithBody(node); - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeNode) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("_super.apply(this, arguments);"); - emitEnd(baseTypeNode); - } - } - emitMemberAssignments(node, 0); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) - statements = statements.slice(1); - emitLines(statements); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - exitNameScope(popFrame); - tempCount = saveTempCount; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); } } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var constructor = ts.getFirstConstructorWithBody(node); + if (constructor) { + emitDecoratorsOfParameters(node, constructor); + } + if (!ts.nodeIsDecorated(node)) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = "); + emitDecorateStart(node.decorators); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + ts.forEach(node.members, function (member) { + if ((member.flags & 128) !== staticFlag) { + return; + } + var decorators; + switch (member.kind) { + case 134: + emitDecoratorsOfParameters(node, member); + decorators = member.decorators; + break; + case 136: + case 137: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + return; + } + if (accessors.setAccessor) { + emitDecoratorsOfParameters(node, accessors.setAccessor); + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + break; + case 132: + decorators = member.decorators; + break; + default: + return; + } + if (!decorators) { + return; + } + writeLine(); + emitStart(member); + if (member.kind !== 132) { + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", "); + } + emitDecorateStart(decorators); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (member.kind !== 132) { + write(", Object.getOwnPropertyDescriptor("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write("))"); + } + write(");"); + emitEnd(member); + writeLine(); + }); + } + function emitDecoratorsOfParameters(node, member) { + ts.forEach(member.parameters, function (parameter, parameterIndex) { + if (!ts.nodeIsDecorated(parameter)) { + return; + } + writeLine(); + emitStart(parameter); + emitDecorateStart(parameter.decorators); + emitStart(parameter.name); + if (member.kind === 135) { + emitDeclarationName(node); + write(", void 0"); + } + else { + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + } + write(", "); + write(String(parameterIndex)); + emitEnd(parameter.name); + write(");"); + emitEnd(parameter); + writeLine(); + }); + } + function emitDecorateStart(decorators) { + write("__decorate(["); + var decoratorCount = decorators.length; + for (var i = 0; i < decoratorCount; i++) { + if (i > 0) { + write(", "); + } + var decorator = decorators[i]; + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + } + write("], "); + } function emitInterfaceDeclaration(node) { - emitPinnedOrTripleSlashComments(node); + emitOnlyPinnedOrTripleSlashComments(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -21047,8 +22186,11 @@ var ts; if (!shouldEmitEnumDeclaration(node)) { return; } - if (!(node.flags & 1)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); emitEnd(node); @@ -21058,7 +22200,7 @@ var ts; emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") {"); increaseIndent(); @@ -21074,7 +22216,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (node.flags & 1) { + if (!isES6ExportedDeclaration(node) && node.flags & 1) { writeLine(); emitStart(node); write("var "); @@ -21091,9 +22233,9 @@ var ts; function emitEnumMember(node) { var enumParent = node.parent; emitStart(node); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); emitExpressionForPropertyName(node.name); write("] = "); @@ -21104,14 +22246,12 @@ var ts; write(";"); } function writeEnumMemberDeclarationValue(member) { - if (!member.initializer || ts.isConst(member.parent)) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; } - if (member.initializer) { + else if (member.initializer) { emit(member.initializer); } else { @@ -21119,7 +22259,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 200) { + if (moduleDeclaration.body.kind === 202) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -21130,9 +22270,12 @@ var ts; function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); write(";"); @@ -21141,18 +22284,16 @@ var ts; emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 201) { - var saveTempCount = tempCount; + if (node.body.kind === 203) { + var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; - var popFrame = enterNameScope(); emit(node.body); - exitNameScope(popFrame); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; } else { @@ -21169,7 +22310,7 @@ var ts; scopeEmitEnd(); } write(")("); - if (node.flags & 1) { + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -21178,7 +22319,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (languageVersion < 2 && node.name.kind === 64 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 65 && node.parent === currentSourceFile) { emitExportMemberAssignments(node.name); } } @@ -21189,199 +22330,303 @@ var ts; emitLiteral(moduleName); emitEnd(moduleName); emitToken(17, moduleName.end); - write(";"); } else { - write("require();"); + write("require()"); } } + function getNamespaceDeclarationNode(node) { + if (node.kind === 205) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 208) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 206 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } function emitImportDeclaration(node) { - var info = getExternalImportInfo(node); - if (info) { - var declarationNode = info.declarationNode; - var namedImports = info.namedImports; + if (languageVersion < 2) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 208) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 205 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); emitStart(node); - var moduleName = ts.getExternalModuleName(node); - if (declarationNode) { - if (!(declarationNode.flags & 1)) + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) write("var "); - emitModuleMemberName(declarationNode); + emitModuleMemberName(namespaceDeclaration); write(" = "); - emitRequire(moduleName); - } - else if (namedImports) { - write("var "); - write(resolver.getGeneratedNameForNode(node)); - write(" = "); - emitRequire(moduleName); } else { - emitRequire(moduleName); + var isNakedImport = 206 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } else { - if (declarationNode) { - if (declarationNode.flags & 1) { - emitModuleMemberName(declarationNode); - write(" = "); - emit(declarationNode.name); - write(";"); - } + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); } } } function emitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitImportDeclaration(node); + emitExternalImportDeclaration(node); return; } if (resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (!(node.flags & 1)) + if (isES6ExportedDeclaration(node)) { + write("export "); write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } } function emitExportDeclaration(node) { - if (node.moduleSpecifier) { - emitStart(node); - var generatedName = resolver.getGeneratedNameForNode(node); - if (compilerOptions.module !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - } - if (node.exportClause) { - ts.forEach(node.exportClause.elements, function (specifier) { + if (languageVersion < 2) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (compilerOptions.module !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _i = 0, _a = node.exportClause.elements, _n = _a.length; _i < _n; _i++) { + var specifier = _a[_i]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write("__export("); + if (compilerOptions.module !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + emitStart(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emitNodeWithoutSourceMap(node.moduleSpecifier); + } + write(";"); + emitEnd(node); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(languageVersion >= 2); + var needsComma = false; + for (var _i = 0, _n = specifiers.length; _i < _n; _i++) { + var specifier = specifiers[_i]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + emitStart(specifier); + if (specifier.propertyName) { + emitNodeWithoutSourceMap(specifier.propertyName); + write(" as "); + } + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (languageVersion >= 2) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 197 && + expression.kind !== 198) { write(";"); - emitEnd(specifier); - }); + } + emitEnd(node); } else { - var tempName = createTempVariable(node).text; writeLine(); - write("for (var " + tempName + " in " + generatedName + ") if (!"); + emitStart(node); emitContainingModuleName(node); - write(".hasOwnProperty(" + tempName + ")) "); - emitContainingModuleName(node); - write("[" + tempName + "] = " + generatedName + "[" + tempName + "];"); - } - emitEnd(node); - } - } - function createExternalImportInfo(node) { - if (node.kind === 203) { - if (node.moduleReference.kind === 213) { - return { - rootNode: node, - declarationNode: node - }; - } - } - else if (node.kind === 204) { - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - return { - rootNode: node, - declarationNode: importClause - }; - } - if (importClause.namedBindings.kind === 206) { - return { - rootNode: node, - declarationNode: importClause.namedBindings - }; - } - return { - rootNode: node, - namedImports: importClause.namedBindings, - localName: resolver.getGeneratedNameForNode(node) - }; - } - return { - rootNode: node - }; - } - else if (node.kind === 210) { - if (node.moduleSpecifier) { - return { - rootNode: node - }; + write(".default = "); + emit(node.expression); + write(";"); + emitEnd(node); } } } - function createExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile) { externalImports = []; exportSpecifiers = {}; - exportDefault = undefined; - ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 210 && !node.moduleSpecifier) { - ts.forEach(node.exportClause.elements, function (specifier) { - if (specifier.name.text === "default") { - exportDefault = exportDefault || specifier; + exportEquals = undefined; + hasExportStars = false; + for (var _i = 0, _a = sourceFile.statements, _n = _a.length; _i < _n; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 206: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); } - var _name = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[_name] || (exportSpecifiers[_name] = [])).push(specifier); - }); - } - else if (node.kind === 209) { - exportDefault = exportDefault || node; - } - else if (node.kind === 195 || node.kind === 196) { - if (node.flags & 1 && node.flags & 256) { - exportDefault = exportDefault || node; - } - } - else { - var info = createExternalImportInfo(node); - if (info) { - if ((!info.declarationNode && !info.namedImports) || resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(info); + break; + case 205: + if (node.moduleReference.kind === 216 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); } - } - } - }); - } - function getExternalImportInfo(node) { - if (externalImports) { - for (var _i = 0, _n = externalImports.length; _i < _n; _i++) { - var info = externalImports[_i]; - if (info.rootNode === node) { - return info; - } + break; + case 212: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _b = 0, _c = node.exportClause.elements, _d = _c.length; _b < _d; _b++) { + var specifier = _c[_b]; + var _name = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[_name] || (exportSpecifiers[_name] = [])).push(specifier); + } + } + break; + case 211: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; } } } - function getFirstExportAssignment(sourceFile) { - return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 209) { - return node; - } - }); - } function sortAMDModules(amdModules) { return amdModules.sort(function (moduleA, moduleB) { if (moduleA.name === moduleB.name) { @@ -21395,7 +22640,20 @@ var ts; } }); } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); writeLine(); write("define("); sortAMDModules(node.amdDependencies); @@ -21403,69 +22661,78 @@ var ts; write("\"" + node.amdModuleName + "\", "); } write("[\"require\", \"exports\""); - ts.forEach(externalImports, function (info) { + for (var _i = 0, _n = externalImports.length; _i < _n; _i++) { + var importNode = externalImports[_i]; write(", "); - var moduleName = ts.getExternalModuleName(info.rootNode); + var moduleName = ts.getExternalModuleName(importNode); if (moduleName.kind === 8) { emitLiteral(moduleName); } else { write("\"\""); } - }); - ts.forEach(node.amdDependencies, function (amdDependency) { + } + for (var _a = 0, _b = node.amdDependencies, _c = _b.length; _a < _c; _a++) { + var amdDependency = _b[_a]; var text = "\"" + amdDependency.path + "\""; write(", "); write(text); - }); + } write("], function (require, exports"); - ts.forEach(externalImports, function (info) { + for (var _d = 0, _e = externalImports.length; _d < _e; _d++) { + var _importNode = externalImports[_d]; write(", "); - if (info.declarationNode) { - emit(info.declarationNode.name); + var namespaceDeclaration = getNamespaceDeclarationNode(_importNode); + if (namespaceDeclaration && !isDefaultImport(_importNode)) { + emit(namespaceDeclaration.name); } else { - write(resolver.getGeneratedNameForNode(info.rootNode)); + write(getGeneratedNameForNode(_importNode)); } - }); - ts.forEach(node.amdDependencies, function (amdDependency) { - if (amdDependency.name) { + } + for (var _f = 0, _g = node.amdDependencies, _h = _g.length; _f < _h; _f++) { + var _amdDependency = _g[_f]; + if (_amdDependency.name) { write(", "); - write(amdDependency.name); + write(_amdDependency.name); } - }); + } write(") {"); increaseIndent(); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - emitExportDefault(node, true); + emitExportEquals(true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + collectExternalModuleInfo(node); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - emitExportDefault(node, false); + emitExportEquals(false); } - function emitExportDefault(sourceFile, emitAsReturn) { - if (exportDefault && resolver.hasExportDefaultValue(sourceFile)) { + function emitES6Module(node, startIndex) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { writeLine(); - emitStart(exportDefault); + emitStart(exportEquals); write(emitAsReturn ? "return " : "module.exports = "); - if (exportDefault.kind === 209) { - emit(exportDefault.expression); - } - else if (exportDefault.kind === 212) { - emit(exportDefault.propertyName); - } - else { - emitDeclarationName(exportDefault); - } + emit(exportEquals.expression); write(";"); - emitEnd(exportDefault); + emitEnd(exportEquals); } } function emitDirectivePrologues(statements, startWithNewLine) { @@ -21482,11 +22749,21 @@ var ts; } return statements.length; } + function writeHelper(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } function emitSourceFileNode(node) { writeLine(); emitDetachedComments(node); var startIndex = emitDirectivePrologues(node.statements, false); - if (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLine(); write("var __extends = this.__extends || function (d, b) {"); increaseIndent(); @@ -21503,9 +22780,15 @@ var ts; write("};"); extendsEmitted = true; } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { + writeHelper("\nvar __decorate = this.__decorate || function (decorators, target, key, value) {\n var kind = typeof (arguments.length == 2 ? value = target : value);\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n switch (kind) {\n case \"function\": value = decorator(value) || value; break;\n case \"number\": decorator(target, key, value); break;\n case \"undefined\": decorator(target, key); break;\n case \"object\": value = decorator(target, key, value) || value; break;\n }\n }\n return value;\n};"); + decorateEmitted = true; + } if (ts.isExternalModule(node)) { - createExternalModuleInfo(node); - if (compilerOptions.module === 2) { + if (languageVersion >= 2) { + emitES6Module(node, startIndex); + } + else if (compilerOptions.module === 2) { emitAMDModule(node, startIndex); } else { @@ -21515,75 +22798,75 @@ var ts; else { externalImports = undefined; exportSpecifiers = undefined; - exportDefault = undefined; + exportEquals = undefined; + hasExportStars = false; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMapWithComments(node) { + function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { if (!node) { return; } if (node.flags & 2) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } var _emitComments = shouldEmitLeadingAndTrailingComments(node); if (_emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node); + emitJavaScriptWorker(node, allowGeneratedIdentifiers); if (_emitComments) { emitTrailingComments(node); } } - function emitNodeWithoutSourceMapWithoutComments(node) { - if (!node) { - return; - } - if (node.flags & 2) { - return emitPinnedOrTripleSlashComments(node); - } - emitJavaScriptWorker(node); - } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 197: - case 195: - case 204: - case 203: - case 198: - case 209: - return false; - case 200: - return shouldEmitModuleDeclaration(node); case 199: + case 197: + case 206: + case 205: + case 200: + case 211: + return false; + case 202: + return shouldEmitModuleDeclaration(node); + case 201: return shouldEmitEnumDeclaration(node); } + if (node.kind !== 176 && + node.parent && + node.parent.kind === 163 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } return true; } - function emitJavaScriptWorker(node) { + function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } switch (node.kind) { - case 64: - return emitIdentifier(node); - case 128: + case 65: + return emitIdentifier(node, allowGeneratedIdentifiers); + case 129: return emitParameter(node); - case 132: - case 131: - return emitMethod(node); case 134: - case 135: + case 133: + return emitMethod(node); + case 136: + case 137: return emitAccessor(node); - case 92: + case 93: return emitThis(node); - case 90: + case 91: return emitSuper(node); - case 88: + case 89: return write("null"); - case 94: + case 95: return write("true"); - case 79: + case 80: return write("false"); case 7: case 8: @@ -21593,125 +22876,127 @@ var ts; case 12: case 13: return emitLiteral(node); - case 169: - return emitTemplateExpression(node); - case 173: - return emitTemplateSpan(node); - case 125: - return emitQualifiedName(node); - case 148: - return emitObjectBindingPattern(node); - case 149: - return emitArrayBindingPattern(node); - case 150: - return emitBindingElement(node); - case 151: - return emitArrayLiteral(node); - case 152: - return emitObjectLiteral(node); - case 218: - return emitPropertyAssignment(node); - case 219: - return emitShorthandPropertyAssignment(node); - case 126: - return emitComputedPropertyName(node); - case 153: - return emitPropertyAccess(node); - case 154: - return emitIndexedAccess(node); - case 155: - return emitCallExpression(node); - case 156: - return emitNewExpression(node); - case 157: - return emitTaggedTemplateExpression(node); - case 158: - return emit(node.expression); - case 159: - return emitParenExpression(node); - case 195: - case 160: - case 161: - return emitFunctionDeclaration(node); - case 162: - return emitDeleteExpression(node); - case 163: - return emitTypeOfExpression(node); - case 164: - return emitVoidExpression(node); - case 165: - return emitPrefixUnaryExpression(node); - case 166: - return emitPostfixUnaryExpression(node); - case 167: - return emitBinaryExpression(node); - case 168: - return emitConditionalExpression(node); case 171: - return emitSpreadElementExpression(node); - case 172: - return; - case 174: - case 201: - return emitBlock(node); + return emitTemplateExpression(node); case 175: - return emitVariableStatement(node); - case 176: - return write(";"); - case 177: - return emitExpressionStatement(node); - case 178: - return emitIfStatement(node); - case 179: - return emitDoStatement(node); - case 180: - return emitWhileStatement(node); - case 181: - return emitForStatement(node); - case 183: - case 182: - return emitForInOrForOfStatement(node); - case 184: - case 185: - return emitBreakOrContinueStatement(node); - case 186: - return emitReturnStatement(node); - case 187: - return emitWithStatement(node); - case 188: - return emitSwitchStatement(node); - case 214: - case 215: - return emitCaseOrDefaultClause(node); - case 189: - return emitLabelledStatement(node); - case 190: - return emitThrowStatement(node); - case 191: - return emitTryStatement(node); - case 217: - return emitCatchClause(node); - case 192: - return emitDebuggerStatement(node); - case 193: - return emitVariableDeclaration(node); - case 196: - return emitClassDeclaration(node); - case 197: - return emitInterfaceDeclaration(node); - case 199: - return emitEnumDeclaration(node); - case 220: - return emitEnumMember(node); - case 200: - return emitModuleDeclaration(node); - case 204: - return emitImportDeclaration(node); - case 203: - return emitImportEqualsDeclaration(node); - case 210: - return emitExportDeclaration(node); + return emitTemplateSpan(node); + case 126: + return emitQualifiedName(node); + case 150: + return emitObjectBindingPattern(node); + case 151: + return emitArrayBindingPattern(node); + case 152: + return emitBindingElement(node); + case 153: + return emitArrayLiteral(node); + case 154: + return emitObjectLiteral(node); case 221: + return emitPropertyAssignment(node); + case 222: + return emitShorthandPropertyAssignment(node); + case 127: + return emitComputedPropertyName(node); + case 155: + return emitPropertyAccess(node); + case 156: + return emitIndexedAccess(node); + case 157: + return emitCallExpression(node); + case 158: + return emitNewExpression(node); + case 159: + return emitTaggedTemplateExpression(node); + case 160: + return emit(node.expression); + case 161: + return emitParenExpression(node); + case 197: + case 162: + case 163: + return emitFunctionDeclaration(node); + case 164: + return emitDeleteExpression(node); + case 165: + return emitTypeOfExpression(node); + case 166: + return emitVoidExpression(node); + case 167: + return emitPrefixUnaryExpression(node); + case 168: + return emitPostfixUnaryExpression(node); + case 169: + return emitBinaryExpression(node); + case 170: + return emitConditionalExpression(node); + case 173: + return emitSpreadElementExpression(node); + case 174: + return; + case 176: + case 203: + return emitBlock(node); + case 177: + return emitVariableStatement(node); + case 178: + return write(";"); + case 179: + return emitExpressionStatement(node); + case 180: + return emitIfStatement(node); + case 181: + return emitDoStatement(node); + case 182: + return emitWhileStatement(node); + case 183: + return emitForStatement(node); + case 185: + case 184: + return emitForInOrForOfStatement(node); + case 186: + case 187: + return emitBreakOrContinueStatement(node); + case 188: + return emitReturnStatement(node); + case 189: + return emitWithStatement(node); + case 190: + return emitSwitchStatement(node); + case 217: + case 218: + return emitCaseOrDefaultClause(node); + case 191: + return emitLabelledStatement(node); + case 192: + return emitThrowStatement(node); + case 193: + return emitTryStatement(node); + case 220: + return emitCatchClause(node); + case 194: + return emitDebuggerStatement(node); + case 195: + return emitVariableDeclaration(node); + case 198: + return emitClassDeclaration(node); + case 199: + return emitInterfaceDeclaration(node); + case 201: + return emitEnumDeclaration(node); + case 223: + return emitEnumMember(node); + case 202: + return emitModuleDeclaration(node); + case 206: + return emitImportDeclaration(node); + case 205: + return emitImportEqualsDeclaration(node); + case 212: + return emitExportDeclaration(node); + case 211: + return emitExportAssignment(node); + case 224: return emitSourceFileNode(node); } } @@ -21728,34 +23013,50 @@ var ts; } return leadingComments; } + function filterComments(ranges, onlyPinnedOrTripleSlashComments) { + if (ranges && onlyPinnedOrTripleSlashComments) { + ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); + if (ranges.length === 0) { + return undefined; + } + } + return ranges; + } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 221 || node.pos !== node.parent.pos) { - var leadingComments; + if (node.parent.kind === 224 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); + return getLeadingCommentsWithoutDetachedComments(); } else { - leadingComments = ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); } - return leadingComments; } } } - function emitLeadingDeclarationComments(node) { - var leadingComments = getLeadingCommentsToEmit(node); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingDeclarationComments(node) { + function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 221 || node.end !== node.parent.end) { - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + if (node.parent.kind === 224 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitLeadingCommentsOfLocalPosition(pos) { + function emitOnlyPinnedOrTripleSlashComments(node) { + emitLeadingCommentsWorker(node, true); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + } + function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { + var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitLeadingCommentsOfPosition(pos) { var leadingComments; if (hasDetachedComments(pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -21763,18 +23064,19 @@ var ts; else { leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + leadingComments = filterComments(leadingComments, compilerOptions.removeComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } - function emitDetachedCommentsAtPosition(node) { + function emitDetachedComments(node) { var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); if (leadingComments) { var detachedComments = []; var lastComment; ts.forEach(leadingComments, function (comment) { if (lastComment) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); if (commentLine >= lastCommentLine + 2) { return detachedComments; } @@ -21783,11 +23085,11 @@ var ts; lastComment = comment; }); if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); - var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -21799,43 +23101,22 @@ var ts; } } } - function emitPinnedOrTripleSlashComments(node) { - var pinnedComments = ts.filter(getLeadingCommentsToEmit(node), isPinnedOrTripleSlashComment); - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; - } + function isPinnedOrTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && + currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { + return true; } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments); - emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment); - } - } - function writeDeclarationFile(jsFilePath, sourceFile) { - var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput; - var appliedSyncOutputPos = 0; - ts.forEach(emitDeclarationResult.aliasDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += aliasEmitInfo.asynchronousOutput; - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos); - writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); if (compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); } } } @@ -21843,10 +23124,28 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + ts.programTime = 0; ts.emitTime = 0; ts.ioReadTime = 0; + ts.ioWriteTime = 0; ts.version = "1.5.0.0"; - function createCompilerHost(options) { + function findConfigFile(searchPath) { + var fileName = "tsconfig.json"; + while (true) { + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; function getCanonicalFileName(fileName) { @@ -21868,29 +23167,31 @@ var ts; } text = ""; } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined; + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } } function writeFile(fileName, data, writeByteOrderMark, onError) { - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } try { + var start = new Date().getTime(); ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); ts.sys.writeFile(fileName, data, writeByteOrderMark); + ts.ioWriteTime += new Date().getTime() - start; } catch (e) { if (onError) { @@ -21911,6 +23212,9 @@ var ts; ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program) { var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics()); + } return ts.sortAndDeduplicateDiagnostics(diagnostics); } ts.getPreEmitDiagnostics = getPreEmitDiagnostics; @@ -21944,14 +23248,16 @@ var ts; var diagnostics = ts.createDiagnosticCollection(); var seenNoDefaultLib = options.noLib; var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var start = new Date().getTime(); host = host || createCompilerHost(options); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); if (!seenNoDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; + ts.programTime += new Date().getTime() - start; program = { getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, @@ -21989,18 +23295,14 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function getDeclarationDiagnostics(targetSourceFile) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(targetSourceFile); - return ts.getDeclarationDiagnostics(getEmitHost(), resolver, targetSourceFile); - } function emit(sourceFile, writeFileCallback) { if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); - var start = new Date().getTime(); + var _start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); - ts.emitTime += new Date().getTime() - start; + ts.emitTime += new Date().getTime() - _start; return emitResult; } function getSourceFile(fileName) { @@ -22023,6 +23325,9 @@ var ts; function getSemanticDiagnostics(sourceFile) { return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); } + function getDeclarationDiagnostics(sourceFile) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + } function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } @@ -22034,6 +23339,13 @@ var ts; var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); } + function getDeclarationDiagnosticsForFile(sourceFile) { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + var writeFile = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + } + } function getGlobalDiagnostics() { var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; @@ -22048,10 +23360,10 @@ var ts; processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; + var _start; var _length; if (refEnd !== undefined && refPos !== undefined) { - start = refPos; + _start = refPos; _length = refEnd - refPos; } var diagnostic; @@ -22077,7 +23389,7 @@ var ts; } if (diagnostic) { if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, start, _length, diagnostic, fileName)); + diagnostics.add(ts.createFileDiagnostic(refFile, _start, _length, diagnostic, fileName)); } else { diagnostics.add(ts.createCompilerDiagnostic(diagnostic, fileName)); @@ -22139,7 +23451,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 204 || node.kind === 203 || node.kind === 210) { + if (node.kind === 206 || node.kind === 205 || node.kind === 212) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -22159,7 +23471,7 @@ var ts; } } } - else if (node.kind === 200 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 202 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -22190,10 +23502,16 @@ var ts; } return; } + var languageVersion = options.target || 0; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (firstExternalModuleSourceFile && !options.module) { - var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + if (!options.module && languageVersion < 2) { + var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + } + } + if (options.module && languageVersion >= 2) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); } if (options.outDir || options.sourceRoot || @@ -22690,22 +24008,6 @@ var ts; function isJSONSupported() { return typeof JSON === "object" && typeof JSON.parse === "function"; } - function findConfigFile() { - var searchPath = ts.normalizePath(ts.sys.getCurrentDirectory()); - var fileName = "tsconfig.json"; - while (true) { - if (ts.sys.fileExists(fileName)) { - return fileName; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - fileName = "../" + fileName; - } - return undefined; - } function executeCommandLine(args) { var commandLine = ts.parseCommandLine(args); var configFileName; @@ -22748,7 +24050,8 @@ var ts; } } else if (commandLine.fileNames.length === 0 && isJSONSupported()) { - configFileName = findConfigFile(); + var searchPath = ts.normalizePath(ts.sys.getCurrentDirectory()); + configFileName = ts.findConfigFile(searchPath); } if (commandLine.fileNames.length === 0 && !configFileName) { printVersion(); @@ -22846,16 +24149,13 @@ var ts; ts.executeCommandLine = executeCommandLine; function compile(fileNames, compilerOptions, compilerHost) { ts.ioReadTime = 0; - ts.parseTime = 0; + ts.ioWriteTime = 0; + ts.programTime = 0; ts.bindTime = 0; ts.checkTime = 0; ts.emitTime = 0; - var start = new Date().getTime(); var program = ts.createProgram(fileNames, compilerOptions, compilerHost); - var programTime = new Date().getTime() - start; var exitStatus = compileProgram(); - var end = new Date().getTime() - start; - var compileTime = end - programTime; if (compilerOptions.listFiles) { ts.forEach(program.getSourceFiles(), function (file) { ts.sys.write(file.fileName + ts.sys.newLine); @@ -22872,14 +24172,13 @@ var ts; if (memoryUsed >= 0) { reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K"); } - reportTimeStatistic("Parse time", programTime); + reportTimeStatistic("I/O read", ts.ioReadTime); + reportTimeStatistic("I/O write", ts.ioWriteTime); + reportTimeStatistic("Parse time", ts.programTime); reportTimeStatistic("Bind time", ts.bindTime); reportTimeStatistic("Check time", ts.checkTime); reportTimeStatistic("Emit time", ts.emitTime); - reportTimeStatistic("Parse time w/o IO", ts.parseTime); - reportTimeStatistic("IO read", ts.ioReadTime); - reportTimeStatistic("Compile time", compileTime); - reportTimeStatistic("Total time", end); + reportTimeStatistic("Total time", ts.programTime + ts.bindTime + ts.checkTime + ts.emitTime); } return { program: program, exitStatus: exitStatus }; function compileProgram() { diff --git a/bin/tsserver.js b/bin/tsserver.js index 44075b1f778..f05e1f27f34 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -28,6 +28,7 @@ var ts; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; })(ts || (ts = {})); +/// var ts; (function (ts) { function forEach(array, callback) { @@ -83,9 +84,9 @@ var ts; if (array) { result = []; for (var _i = 0, _n = array.length; _i < _n; _i++) { - var _item = array[_i]; - if (f(_item)) { - result.push(_item); + var item_1 = array[_i]; + if (f(item_1)) { + result.push(item_1); } } } @@ -117,9 +118,9 @@ var ts; if (array) { result = []; for (var _i = 0, _n = array.length; _i < _n; _i++) { - var _item = array[_i]; - if (!contains(result, _item)) { - result.push(_item); + var item_2 = array[_i]; + if (!contains(result, item_2)) { + result.push(item_2); } } } @@ -136,9 +137,11 @@ var ts; } ts.sum = sum; function addRange(to, from) { - for (var _i = 0, _n = from.length; _i < _n; _i++) { - var v = from[_i]; - to.push(v); + if (to && from) { + for (var _i = 0, _n = from.length; _i < _n; _i++) { + var v = from[_i]; + to.push(v); + } } } ts.addRange = addRange; @@ -168,6 +171,35 @@ var ts; return ~low; } ts.binarySearch = binarySearch; + function reduceLeft(array, f, initial) { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + function reduceRight(array, f, initial) { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + ts.reduceRight = reduceRight; var hasOwnProperty = Object.prototype.hasOwnProperty; function hasProperty(map, key) { return hasOwnProperty.call(map, key); @@ -199,9 +231,9 @@ var ts; for (var id in first) { result[id] = first[id]; } - for (var _id in second) { - if (!hasProperty(result, _id)) { - result[_id] = second[_id]; + for (var id in second) { + if (!hasProperty(result, id)) { + result[id] = second[id]; } } return result; @@ -229,14 +261,6 @@ var ts; return hasProperty(map, key) ? map[key] : undefined; } ts.lookUp = lookUp; - function mapToArray(map) { - var result = []; - for (var id in map) { - result.push(map[id]); - } - return result; - } - ts.mapToArray = mapToArray; function copyMap(source, target) { for (var p in source) { target[p] = source[p]; @@ -462,6 +486,9 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { + // Get root length of http://www.website.com/folder1/foler2/ + // In this example the root is: http://www.website.com/ + // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { @@ -624,6 +651,7 @@ var ts; Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { ts.sys = (function () { @@ -698,9 +726,9 @@ var ts; var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); for (var _i = 0, _n = files.length; _i < _n; _i++) { - var _name = files[_i]; - if (!extension || ts.fileExtensionIs(_name, extension)) { - result.push(ts.combinePaths(path, _name)); + var name_1 = files[_i]; + if (!extension || ts.fileExtensionIs(name_1, extension)) { + result.push(ts.combinePaths(path, name_1)); } } var subfolders = getNames(folder.subfolders); @@ -805,8 +833,8 @@ var ts; } } for (var _a = 0, _b = directories.length; _a < _b; _a++) { - var _current = directories[_a]; - visitDirectory(_current); + var current = directories[_a]; + visitDirectory(current); } } } @@ -875,559 +903,573 @@ var ts; } })(); })(ts || (ts = {})); +/// var ts; (function (ts) { ts.Diagnostics = { - Unterminated_string_literal: { code: 1002, category: 1, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: 1, key: "Identifier expected." }, - _0_expected: { code: 1005, category: 1, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: 1, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: 1, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: 1, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: 1, key: "Unexpected token." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: 1, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: 1, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: 1, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: 1, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: 1, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: 1, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: 1, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: 1, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: 1, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: 1, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: 1, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: 1, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: 1, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: 1, key: "A class declaration can only have one 'implements' clause." }, - Accessibility_modifier_already_seen: { code: 1028, category: 1, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: 1, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: 1, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: 1, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: 1, key: "An interface declaration cannot have an 'implements' clause." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: 1, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: 1, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: 1, key: "Statements are not allowed in ambient contexts." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: 1, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: 1, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: 1, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: 1, key: "A 'declare' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: 1, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: 1, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: 1, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: 1, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: 1, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: 1, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: 1, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: 1, key: "A 'get' accessor cannot have parameters." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: 1, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - Enum_member_must_have_initializer: { code: 1061, category: 1, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: 1, key: "An export assignment cannot be used in an internal module." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: 1, key: "Ambient enum elements can only have integer literal initializers." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: 1, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: 1, key: "A 'declare' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: 1, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: 1, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: 1, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: 1, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: 1, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: 1, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: 1, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: 1, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: 1, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: 1, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: 1, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: 1, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: 1, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: 1, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: 1, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: 1, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: 1, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: 1, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: 1, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: 1, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: 1, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: 1, key: "Expression expected." }, - Type_expected: { code: 1110, category: 1, key: "Type expected." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: 1, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: 1, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: 1, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: 1, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: 1, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: 1, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: 1, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: 1, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: 1, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: 1, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: 1, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: 1, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: 1, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: 1, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: 1, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: 1, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: 1, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: 1, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: 1, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: 1, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: 1, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: 1, key: "Type reference expected." }, - Variable_declaration_expected: { code: 1134, category: 1, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: 1, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: 1, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: 1, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: 1, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: 1, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: 1, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: 1, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: 1, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: 1, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: 1, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: 1, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: 1, key: "Import declarations in an internal module cannot reference an external module." }, - Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: 1, key: "Cannot compile external modules unless the '--module' flag is provided." }, - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: 1, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: 1, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: 1, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: 1, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: 1, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_must_be_initialized: { code: 1155, category: 1, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1, key: "'let' declarations can only be declared inside a block." }, - Unterminated_template_literal: { code: 1160, category: 1, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: 1, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: 1, key: "An object member cannot be declared optional." }, - yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1, key: "'yield' expression must be contained_within a generator declaration." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: 1, key: "Computed property names are not allowed in enums." }, - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: 1, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: 1, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: 1, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: 1, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: 1, key: "A computed property name in an interface must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: 1, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: 1, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: 1, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: 1, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: 1, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: 1, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: 1, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: 1, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: 1, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: 1, key: "Unexpected token. '{' expected." }, - Property_destructuring_pattern_expected: { code: 1180, category: 1, key: "Property destructuring pattern expected." }, - Array_element_destructuring_pattern_expected: { code: 1181, category: 1, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: 1, key: "A destructuring declaration must have an initializer." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: 1, key: "Destructuring declarations are not allowed in ambient contexts." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: 1, key: "An implementation cannot be declared in ambient contexts." }, - Modifiers_cannot_appear_here: { code: 1184, category: 1, key: "Modifiers cannot appear here." }, - Merge_conflict_marker_encountered: { code: 1185, category: 1, key: "Merge conflict marker encountered." }, - A_rest_element_cannot_have_an_initializer: { code: 1186, category: 1, key: "A rest element cannot have an initializer." }, - A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: 1, key: "A parameter property may not be a binding pattern." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: 1, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: 1, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: 1, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, - An_import_declaration_cannot_have_modifiers: { code: 1191, category: 1, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export_or_export_assignment: { code: 1192, category: 1, key: "External module '{0}' has no default export or export assignment." }, - An_export_declaration_cannot_have_modifiers: { code: 1193, category: 1, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: 1, key: "Export declarations are not permitted in an internal module." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: 1, key: "Catch clause variable name must be an identifier." }, - Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: 1, key: "Catch clause variable cannot have a type annotation." }, - Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: 1, key: "Catch clause variable cannot have an initializer." }, - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: 1, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, - Unterminated_Unicode_escape_sequence: { code: 1199, category: 1, key: "Unterminated Unicode escape sequence." }, - Duplicate_identifier_0: { code: 2300, category: 1, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: 1, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: 1, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: 1, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_an_external_module: { code: 2306, category: 1, key: "File '{0}' is not an external module." }, - Cannot_find_external_module_0: { code: 2307, category: 1, key: "Cannot find external module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: 1, key: "A module cannot have more than one export assignment." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: 1, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: 1, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: 1, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: 1, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: 1, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: 1, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: 1, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: 1, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: 1, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: 1, key: "Cannot find global type '{0}'." }, - Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: 1, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: 1, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: 1, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: 1, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: 1, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: 1, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: 1, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: 1, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: 1, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: 1, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: 1, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_body: { code: 2331, category: 1, key: "'this' cannot be referenced in a module body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: 1, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: 1, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: 1, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: 1, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: 1, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: 1, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: 1, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: 1, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: 1, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: 1, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: 1, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: 1, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: 1, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: 1, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: 1, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: 1, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: 1, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: 1, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: 1, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: 1, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: 1, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: 1, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: 1, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: 1, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: 1, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: 1, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: 1, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: 1, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: 1, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: 1, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: 1, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: 1, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: 1, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: 1, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: 1, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: 1, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: 1, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: 1, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: 1, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: 1, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: 1, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: 1, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: 1, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: 1, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: 1, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: 1, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: 1, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: 1, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: 1, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: 1, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: 1, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: 1, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: 1, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: 1, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: 1, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: 1, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: 1, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: 1, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: 1, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: 1, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: 1, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: 1, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: 1, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: 1, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: 1, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: 1, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: 1, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: 1, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: 1, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: 1, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: 1, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: 1, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: 1, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: 1, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: 1, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: 1, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: 1, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: 1, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: 1, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: 1, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: 1, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: 1, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: 1, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: 1, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: 1, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: 1, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: 1, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: 1, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: 1, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: 1, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: 1, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: 1, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, - A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: 1, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: 1, key: "Ambient external modules cannot be nested in other modules." }, - Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: 1, key: "Ambient external module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: 1, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: 1, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: 1, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: 1, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: 1, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: 1, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: 1, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: 1, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: 1, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: 1, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: 1, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: 1, key: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: 1, key: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: 1, key: "Left-hand side of assignment expression cannot be a constant." }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: 1, key: "Cannot redeclare block-scoped variable '{0}'." }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: 1, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: 1, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: 1, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: 1, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: 1, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: 1, key: "An AMD module cannot have multiple name assignments." }, - Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: 1, key: "Type '{0}' has no property '{1}' and no string index signature." }, - Type_0_has_no_property_1: { code: 2460, category: 1, key: "Type '{0}' has no property '{1}'." }, - Type_0_is_not_an_array_type: { code: 2461, category: 1, key: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: 1, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: 1, key: "A binding pattern parameter cannot be optional in an implementation signature." }, - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: 1, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, - this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: 1, key: "'this' cannot be referenced in a computed property name." }, - super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: 1, key: "'super' cannot be referenced in a computed property name." }, - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: 1, key: "A computed property name cannot reference a type parameter from its containing type." }, - Cannot_find_global_value_0: { code: 2468, category: 1, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: 1, key: "The '{0}' operator cannot be applied to type 'symbol'." }, - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: 1, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: 1, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: 1, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: 1, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: 1, key: "In 'const' enum declarations member initializer must be constant expression." }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: 1, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: 1, key: "A const enum member can only be accessed using a string literal." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: 1, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: 1, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: 1, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: 1, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: 1, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: 1, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, - Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: 1, key: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: 1, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: 1, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: 1, key: "Invalid left-hand side in 'for...of' statement." }, - The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: 1, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, - The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: 1, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: 1, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: 1, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: 1, key: "Cannot redeclare identifier '{0}' in catch clause" }, - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: 1, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: 1, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2461, category: 1, key: "Type '{0}' is not an array type or a string type." }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: 1, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: 1, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: 1, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: 1, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: 1, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: 1, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: 1, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: 1, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: 1, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: 1, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: 1, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: 1, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: 1, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: 1, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: 1, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: 1, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: 1, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: 1, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: 1, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: 1, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: 1, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: 1, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: 1, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: 1, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: 1, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: 1, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: 1, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: 1, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: 1, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: 1, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: 1, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: 1, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: 1, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: 1, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: 1, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: 1, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: 1, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: 1, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: 1, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: 1, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: 1, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: 1, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: 1, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: 1, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: 1, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: 1, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: 1, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: 1, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: 1, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: 1, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: 1, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: 1, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: 1, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: 1, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: 1, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: 1, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: 1, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: 1, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: 1, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: 1, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: 1, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: 1, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: 1, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: 1, key: "Unsupported file encoding." }, - Unknown_compiler_option_0: { code: 5023, category: 1, key: "Unknown compiler option '{0}'." }, - Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: 1, key: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: 1, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: 1, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: 1, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: 1, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: 1, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: 1, key: "Option 'project' cannot be mixed with source files on a command line." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: 2, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: 2, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: 2, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: 2, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: 2, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: 2, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: 2, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: 2, key: "Do not emit outputs if any type checking errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: 2, key: "Do not emit comments to output." }, - Do_not_emit_outputs: { code: 6010, category: 2, key: "Do not emit outputs." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: 2, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: 2, key: "Specify module code generation: 'commonjs' or 'amd'" }, - Print_this_message: { code: 6017, category: 2, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: 2, key: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: 2, key: "Compile the project in the given directory." }, - Syntax_Colon_0: { code: 6023, category: 2, key: "Syntax: {0}" }, - options: { code: 6024, category: 2, key: "options" }, - file: { code: 6025, category: 2, key: "file" }, - Examples_Colon_0: { code: 6026, category: 2, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: 2, key: "Options:" }, - Version_0: { code: 6029, category: 2, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: 2, key: "Insert command line options and files from a file." }, - File_change_detected_Starting_incremental_compilation: { code: 6032, category: 2, key: "File change detected. Starting incremental compilation..." }, - KIND: { code: 6034, category: 2, key: "KIND" }, - FILE: { code: 6035, category: 2, key: "FILE" }, - VERSION: { code: 6036, category: 2, key: "VERSION" }, - LOCATION: { code: 6037, category: 2, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: 2, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: 2, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: 2, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: 1, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: 1, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: 1, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: 1, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: 1, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: 1, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: 1, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: 1, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2, key: "Raise error on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: 1, key: "File '{0}' not found." }, - File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: 2, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: 2, key: "Preserve new-lines when emitting code." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: 1, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: 1, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: 1, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: 1, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: 1, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: 1, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: 1, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: 1, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: 1, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: 1, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: 1, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: 1, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: 1, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, - _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: 1, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: 1, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: 1, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - You_cannot_rename_this_element: { code: 8000, category: 1, key: "You cannot rename this element." }, - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: 1, key: "You cannot rename elements that are defined in the standard TypeScript library." }, - yield_expressions_are_not_currently_supported: { code: 9000, category: 1, key: "'yield' expressions are not currently supported." }, - Generators_are_not_currently_supported: { code: 9001, category: 1, key: "Generators are not currently supported." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: 1, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." } + Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated string literal." }, + Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier expected." }, + _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, + Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing comma not allowed." }, + Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "'*/' expected." }, + Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected token." }, + A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, + Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, + A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, + An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, + An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, + An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, + An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, + An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, + An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, + An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, + A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, + A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: ts.DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, + Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, + _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, + _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, + _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, + An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: ts.DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, + super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, + Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, + Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, + Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, + A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, + A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, + A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, + A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, + A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, + A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, + An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." }, + Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, + A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, + _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, + _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, + Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, + Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, + An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, + A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, + An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, + _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, + Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, + Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, + with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, + delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, + Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, + A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, + Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression expected." }, + Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type expected." }, + A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, + An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, + Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, + A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, + Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, + Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit expected." }, + Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, + Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected end of text." }, + Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid character." }, + Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration or statement expected." }, + Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement expected." }, + case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, + Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, + Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, + Type_reference_expected: { code: 1133, category: ts.DiagnosticCategory.Error, key: "Type reference expected." }, + Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, + Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, + Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, + Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression or comma expected." }, + Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter declaration expected." }, + Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type parameter declaration expected." }, + Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type argument expected." }, + String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String literal expected." }, + Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line break not permitted here." }, + or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, + Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, + Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." }, + Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." }, + File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, + let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: ts.DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, + const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: ts.DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, + const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, + let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, + Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated template literal." }, + Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, + yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: ts.DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, + A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: ts.DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, + A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, + Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, + Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, + A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, + A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, + An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, + External_module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "External module '{0}' has no default export." }, + An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, + Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, + Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, + Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, + Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, + Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, + A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: ts.DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, + Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, + Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, + Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, + Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, + Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, + Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, + File_0_is_not_an_external_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not an external module." }, + Cannot_find_external_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find external module '{0}'." }, + A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, + Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, + A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, + An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An interface may only extend a class or another interface." }, + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, + Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic type '{0}' requires {1} type argument(s)." }, + Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not generic." }, + Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." }, + Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." }, + Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot find global type '{0}'." }, + Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, + Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, + Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, + Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, + Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, + Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, + Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, + Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, + Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, + Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, + Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, + this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, + this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, + this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, + this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, + super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, + super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, + Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, + Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, + Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot invoke an expression whose type lacks a call signature." }, + Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, + Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, + Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, + Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, + A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, + A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A parameter initializer is only allowed in a function or constructor implementation." }, + Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' cannot be referenced in its initializer." }, + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, + Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate string index signature." }, + Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate number index signature." }, + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, + Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, + A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, + get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, + A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, + Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, + Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, + Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, + Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function overload must be static." }, + Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function overload must not be static." }, + Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." }, + Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor implementation is missing." }, + Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." }, + Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, + Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, + Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, + Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." }, + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, + Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, + All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, + Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, + Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, + Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, + Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, + Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, + Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, + Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly implements interface '{1}'." }, + A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A class may only implement another class or interface." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, + Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface name cannot be '{0}'" }, + All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." }, + Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, + Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, + A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, + A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient external modules cannot be nested in other modules." }, + Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, + Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, + Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, + Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, + Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." }, + Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." }, + An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." }, + The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, + Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, + Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, + An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, + A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, + this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." }, + super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, + Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, + The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, + Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, + A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, + Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, + Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, + The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, + The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, + Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, + Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, + The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." }, + External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, + Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, + Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, + Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, + Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, + Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, + Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, + The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, + Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, + Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, + Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, + Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, + Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, + Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, + Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, + Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch input files." }, + Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, + Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any type checking errors were reported." }, + Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, + Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, + Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, + Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, + Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, + Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, + Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax: {0}" }, + options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options" }, + file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file" }, + Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples: {0}" }, + Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options:" }, + Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version {0}" }, + Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, + File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, + KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND" }, + FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE" }, + VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION" }, + LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION" }, + DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY" }, + Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, + Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, + Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, + Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, + Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, + Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, + Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, + Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, + Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, + File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File '{0}' not found." }, + File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, + Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, + Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, + Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, + Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, + Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index signature of object type implicitly has an 'any' type." }, + Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, + Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, + _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, + _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, + You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, + yield_expressions_are_not_currently_supported: { code: 9000, category: ts.DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, + Generators_are_not_currently_supported: { code: 9001, category: ts.DiagnosticCategory.Error, key: "Generators are not currently supported." } }; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { var textToToken = { - "any": 111, - "as": 101, - "boolean": 112, - "break": 65, - "case": 66, - "catch": 67, - "class": 68, - "continue": 70, - "const": 69, - "constructor": 113, - "debugger": 71, - "declare": 114, - "default": 72, - "delete": 73, - "do": 74, - "else": 75, - "enum": 76, - "export": 77, - "extends": 78, - "false": 79, - "finally": 80, - "for": 81, - "from": 123, - "function": 82, - "get": 115, - "if": 83, - "implements": 102, - "import": 84, - "in": 85, - "instanceof": 86, - "interface": 103, - "let": 104, - "module": 116, - "new": 87, - "null": 88, - "number": 118, - "package": 105, - "private": 106, - "protected": 107, - "public": 108, - "require": 117, - "return": 89, - "set": 119, - "static": 109, - "string": 120, - "super": 90, - "switch": 91, - "symbol": 121, - "this": 92, - "throw": 93, - "true": 94, - "try": 95, - "type": 122, - "typeof": 96, - "var": 97, - "void": 98, - "while": 99, - "with": 100, - "yield": 110, - "of": 124, + "any": 112, + "as": 102, + "boolean": 113, + "break": 66, + "case": 67, + "catch": 68, + "class": 69, + "continue": 71, + "const": 70, + "constructor": 114, + "debugger": 72, + "declare": 115, + "default": 73, + "delete": 74, + "do": 75, + "else": 76, + "enum": 77, + "export": 78, + "extends": 79, + "false": 80, + "finally": 81, + "for": 82, + "from": 124, + "function": 83, + "get": 116, + "if": 84, + "implements": 103, + "import": 85, + "in": 86, + "instanceof": 87, + "interface": 104, + "let": 105, + "module": 117, + "new": 88, + "null": 89, + "number": 119, + "package": 106, + "private": 107, + "protected": 108, + "public": 109, + "require": 118, + "return": 90, + "set": 120, + "static": 110, + "string": 121, + "super": 91, + "switch": 92, + "symbol": 122, + "this": 93, + "throw": 94, + "true": 95, + "try": 96, + "type": 123, + "typeof": 97, + "var": 98, + "void": 99, + "while": 100, + "with": 101, + "yield": 111, + "of": 125, "{": 14, "}": 15, "(": 16, @@ -1466,18 +1508,19 @@ var ts; "||": 49, "?": 50, ":": 51, - "=": 52, - "+=": 53, - "-=": 54, - "*=": 55, - "/=": 56, - "%=": 57, - "<<=": 58, - ">>=": 59, - ">>>=": 60, - "&=": 61, - "|=": 62, - "^=": 63 + "=": 53, + "+=": 54, + "-=": 55, + "*=": 56, + "/=": 57, + "%=": 58, + "<<=": 59, + ">>=": 60, + ">>>=": 61, + "&=": 62, + "|=": 63, + "^=": 64, + "@": 52 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1518,9 +1561,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var _name in source) { - if (source.hasOwnProperty(_name)) { - result[source[_name]] = _name; + for (var name_2 in source) { + if (source.hasOwnProperty(name_2)) { + result[source[name_2]] = name_2; } } return result; @@ -1530,6 +1573,10 @@ var ts; return tokenStrings[t]; } ts.tokenToString = tokenToString; + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; function computeLineStarts(text) { var result = new Array(); var pos = 0; @@ -1587,13 +1634,35 @@ var ts; ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { - return ch === 32 || ch === 9 || ch === 11 || ch === 12 || - ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 || - ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279; + return ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; } ts.isWhiteSpace = isWhiteSpace; function isLineBreak(ch) { - return ch === 10 || ch === 13 || ch === 8232 || ch === 8233 || ch === 133; + // ES5 7.3: + // The ECMAScript line terminator characters are listed in Table 3. + // Table 3 � Line Terminator Characters + // Code Unit Value Name Formal Name + // \u000A Line Feed + // \u000D Carriage Return + // \u2028 Line separator + // \u2029 Paragraph separator + // Only the characters in Table 3 are treated as line terminators. Other new line or line + // breaking characters are treated as white space but not as line terminators. + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; } ts.isLineBreak = isLineBreak; function isDigit(ch) { @@ -1696,8 +1765,8 @@ var ts; else { ts.Debug.assert(ch === 61); while (pos < len) { - var _ch = text.charCodeAt(pos); - if (_ch === 62 && isConflictMarkerTrivia(text, pos)) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -1712,8 +1781,9 @@ var ts; var ch = text.charCodeAt(pos); switch (ch) { case 13: - if (text.charCodeAt(pos + 1) === 10) + if (text.charCodeAt(pos + 1) === 10) { pos++; + } case 10: pos++; if (trailing) { @@ -1755,8 +1825,9 @@ var ts; } } if (collecting) { - if (!result) + if (!result) { result = []; + } result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine }); } continue; @@ -2095,14 +2166,14 @@ var ts; return result; } function getIdentifierToken() { - var _len = tokenValue.length; - if (_len >= 2 && _len <= 11) { + var len = tokenValue.length; + if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { return token = textToToken[tokenValue]; } } - return token = 64; + return token = 65; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2181,7 +2252,7 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 37; case 38: @@ -2189,7 +2260,7 @@ var ts; return pos += 2, token = 48; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } return pos++, token = 43; case 40: @@ -2198,7 +2269,7 @@ var ts; return pos++, token = 17; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; + return pos += 2, token = 56; } return pos++, token = 35; case 43: @@ -2206,7 +2277,7 @@ var ts; return pos += 2, token = 38; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 53; + return pos += 2, token = 54; } return pos++, token = 33; case 44: @@ -2216,7 +2287,7 @@ var ts; return pos += 2, token = 39; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 54; + return pos += 2, token = 55; } return pos++, token = 34; case 46: @@ -2248,13 +2319,13 @@ var ts; pos += 2; var commentClosed = false; while (pos < len) { - var _ch = text.charCodeAt(pos); - if (_ch === 42 && text.charCodeAt(pos + 1) === 47) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { pos += 2; commentClosed = true; break; } - if (isLineBreak(_ch)) { + if (isLineBreak(ch_2)) { precedingLineBreak = true; } pos++; @@ -2271,7 +2342,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 36; case 48: @@ -2287,22 +2358,22 @@ var ts; } else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; - var _value = scanBinaryOrOctalDigits(2); - if (_value < 0) { + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); - _value = 0; + value = 0; } - tokenValue = "" + _value; + tokenValue = "" + value; return token = 7; } else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; - var _value_1 = scanBinaryOrOctalDigits(8); - if (_value_1 < 0) { + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); - _value_1 = 0; + value = 0; } - tokenValue = "" + _value_1; + tokenValue = "" + value; return token = 7; } if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { @@ -2336,7 +2407,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 58; + return pos += 3, token = 59; } return pos += 2, token = 40; } @@ -2363,7 +2434,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 32; } - return pos++, token = 52; + return pos++, token = 53; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2383,7 +2454,7 @@ var ts; return pos++, token = 19; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } return pos++, token = 45; case 123: @@ -2393,13 +2464,15 @@ var ts; return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } return pos++, token = 44; case 125: return pos++, token = 15; case 126: return pos++, token = 47; + case 64: + return pos++, token = 52; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2439,12 +2512,12 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } return pos++, token = 41; } @@ -2455,7 +2528,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 36 || token === 56) { + if (token === 36 || token === 57) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2549,8 +2622,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 64 || token > 100; }, - isReservedWord: function () { return token >= 65 && token <= 100; }, + isIdentifier: function () { return token === 65 || token > 101; }, + isReservedWord: function () { return token >= 66 && token <= 101; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2564,6 +2637,10 @@ var ts; } ts.createScanner = createScanner; })(ts || (ts = {})); +/// +/// +/// +/// var ts; (function (ts) { ts.optionDeclarations = [ @@ -2914,6 +2991,7 @@ var ts; } ts.parseConfigFile = parseConfigFile; })(ts || (ts = {})); +/// var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { @@ -2962,21 +3040,21 @@ var ts; ts.getFullWidth = getFullWidth; function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 32) !== 0; + return (node.parserContextFlags & 64) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 64)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || + if (!(node.parserContextFlags & 128)) { + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 32) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 32; + node.parserContextFlags |= 64; } - node.parserContextFlags |= 64; + node.parserContextFlags |= 128; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 221) { + while (node && node.kind !== 224) { node = node.parent; } return node; @@ -3058,15 +3136,15 @@ var ts; return current; } switch (current.kind) { - case 221: + case 224: + case 204: + case 220: case 202: - case 217: - case 200: - case 181: - case 182: case 183: + case 184: + case 185: return current; - case 174: + case 176: if (!isFunctionLike(current.parent)) { return current; } @@ -3077,9 +3155,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 193 && + declaration.kind === 195 && declaration.parent && - declaration.parent.kind === 217; + declaration.parent.kind === 220; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3116,15 +3194,15 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 193: - case 150: - case 196: - case 197: - case 200: - case 199: - case 220: case 195: - case 160: + case 152: + case 198: + case 199: + case 202: + case 201: + case 223: + case 197: + case 162: errorNode = node.name; break; } @@ -3146,11 +3224,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 199 && isConst(node); + return node.kind === 201 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 150 || isBindingPattern(node))) { + while (node && (node.kind === 152 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3158,14 +3236,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 193) { + if (node.kind === 195) { node = node.parent; } - if (node && node.kind === 194) { + if (node && node.kind === 196) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 175) { + if (node && node.kind === 177) { flags |= node.flags; } return flags; @@ -3180,12 +3258,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 177 && node.expression.kind === 8; + return node.kind === 179 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 128 || node.kind === 127) { + if (node.kind === 129 || node.kind === 128) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3207,23 +3284,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 186: + case 188: return visitor(node); - case 202: - case 174: - case 178: - case 179: + case 204: + case 176: case 180: case 181: case 182: case 183: - case 187: - case 188: - case 214: - case 215: + case 184: + case 185: case 189: - case 191: + case 190: case 217: + case 218: + case 191: + case 193: + case 220: return ts.forEachChild(node, traverse); } } @@ -3232,14 +3309,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 150: - case 220: - case 128: - case 218: - case 130: + case 152: + case 223: case 129: - case 219: - case 193: + case 221: + case 132: + case 131: + case 222: + case 195: return true; } } @@ -3249,22 +3326,22 @@ var ts; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 133: - case 160: - case 195: - case 161: - case 132: - case 131: - case 134: case 135: + case 162: + case 197: + case 163: + case 134: + case 133: case 136: case 137: case 138: + case 139: case 140: - case 141: - case 160: - case 161: - case 195: + case 142: + case 143: + case 162: + case 163: + case 197: return true; } } @@ -3272,11 +3349,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 174 && isFunctionLike(node.parent); + return node && node.kind === 176 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 132 && node.parent.kind === 152; + return node && node.kind === 134 && node.parent.kind === 154; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3295,28 +3372,28 @@ var ts; return undefined; } switch (node.kind) { - case 126: - if (node.parent.parent.kind === 196) { + case 127: + if (node.parent.parent.kind === 198) { return node; } node = node.parent; break; - case 161: + case 163: if (!includeArrowFunctions) { continue; } - case 195: - case 160: - case 200: - case 130: - case 129: + case 197: + case 162: + case 202: case 132: case 131: - case 133: case 134: + case 133: case 135: - case 199: - case 221: + case 136: + case 137: + case 201: + case 224: return node; } } @@ -3328,47 +3405,104 @@ var ts; if (!node) return node; switch (node.kind) { - case 126: - if (node.parent.parent.kind === 196) { + case 127: + if (node.parent.parent.kind === 198) { return node; } node = node.parent; break; - case 195: - case 160: - case 161: + case 197: + case 162: + case 163: if (!includeFunctions) { continue; } - case 130: - case 129: case 132: case 131: - case 133: case 134: + case 133: case 135: + case 136: + case 137: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 157) { + if (node.kind === 159) { return node.tag; } return node.expression; } ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 198: + return true; + case 132: + return node.parent.kind === 198; + case 129: + return node.parent.body && node.parent.parent.kind === 198; + case 136: + case 137: + case 134: + return node.body && node.parent.kind === 198; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + switch (node.kind) { + case 198: + if (node.decorators) { + return true; + } + return false; + case 132: + case 129: + if (node.decorators) { + return true; + } + return false; + case 136: + if (node.body && node.decorators) { + return true; + } + return false; + case 134: + case 137: + if (node.body && node.decorators) { + return true; + } + return false; + } + return false; + } + ts.nodeIsDecorated = nodeIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 198: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 134: + case 137: + return ts.forEach(node.parameters, nodeIsDecorated); + } + return false; + } + ts.childIsDecorated = childIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: case 9: - case 151: - case 152: case 153: case 154: case 155: @@ -3378,68 +3512,70 @@ var ts; case 159: case 160: case 161: - case 164: case 162: case 163: - case 165: case 166: + case 164: + case 165: case 167: case 168: - case 171: case 169: + case 170: + case 173: + case 171: case 10: - case 172: + case 174: return true; - case 125: - while (node.parent.kind === 125) { + case 126: + while (node.parent.kind === 126) { node = node.parent; } - return node.parent.kind === 142; - case 64: - if (node.parent.kind === 142) { + return node.parent.kind === 144; + case 65: + if (node.parent.kind === 144) { return true; } case 7: case 8: - var _parent = node.parent; - switch (_parent.kind) { - case 193: - case 128: - case 130: + var parent_1 = node.parent; + switch (parent_1.kind) { + case 195: case 129: - case 220: - case 218: - case 150: - return _parent.initializer === node; - case 177: - case 178: + case 132: + case 131: + case 223: + case 221: + case 152: + return parent_1.initializer === node; case 179: case 180: - case 186: - case 187: - case 188: - case 214: - case 190: - case 188: - return _parent.expression === node; case 181: - var forStatement = _parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 194) || + case 182: + case 188: + case 189: + case 190: + case 217: + case 192: + case 190: + return parent_1.expression === node; + case 183: + var forStatement = parent_1; + return (forStatement.initializer === node && forStatement.initializer.kind !== 196) || forStatement.condition === node || forStatement.iterator === node; - case 182: - case 183: - var forInStatement = _parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 194) || + case 184: + case 185: + var forInStatement = parent_1; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 196) || forInStatement.expression === node; - case 158: - return node === _parent.expression; - case 173: - return node === _parent.expression; - case 126: - return node === _parent.expression; + case 160: + return node === parent_1.expression; + case 175: + return node === parent_1.expression; + case 127: + return node === parent_1.expression; default: - if (isExpression(_parent)) { + if (isExpression(parent_1)) { return true; } } @@ -3454,7 +3590,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 203 && node.moduleReference.kind === 213; + return node.kind === 205 && node.moduleReference.kind === 216; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3463,41 +3599,41 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 203 && node.moduleReference.kind !== 213; + return node.kind === 205 && node.moduleReference.kind !== 216; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 204) { + if (node.kind === 206) { return node.moduleSpecifier; } - if (node.kind === 203) { + if (node.kind === 205) { var reference = node.moduleReference; - if (reference.kind === 213) { + if (reference.kind === 216) { return reference.expression; } } - if (node.kind === 210) { + if (node.kind === 212) { return node.moduleSpecifier; } } ts.getExternalModuleName = getExternalModuleName; function hasDotDotDotToken(node) { - return node && node.kind === 128 && node.dotDotDotToken !== undefined; + return node && node.kind === 129 && node.dotDotDotToken !== undefined; } ts.hasDotDotDotToken = hasDotDotDotToken; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 128: + case 129: return node.questionToken !== undefined; + case 134: + case 133: + return node.questionToken !== undefined; + case 222: + case 221: case 132: case 131: return node.questionToken !== undefined; - case 219: - case 218: - case 130: - case 129: - return node.questionToken !== undefined; } } return false; @@ -3520,7 +3656,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 149 || node.kind === 148); + return !!node && (node.kind === 151 || node.kind === 150); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -3535,33 +3671,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 161: - case 150: - case 196: - case 133: - case 199: - case 220: - case 212: - case 195: - case 160: - case 134: - case 205: - case 203: - case 208: + case 163: + case 152: + case 198: + case 135: + case 201: + case 223: + case 214: case 197: + case 162: + case 136: + case 207: + case 205: + case 210: + case 199: + case 134: + case 133: + case 202: + case 208: + case 129: + case 221: case 132: case 131: + case 137: + case 222: case 200: - case 206: case 128: - case 218: - case 130: - case 129: - case 135: - case 219: - case 198: - case 127: - case 193: + case 195: return true; } return false; @@ -3569,59 +3705,82 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 185: - case 184: - case 192: - case 179: - case 177: - case 176: - case 182: - case 183: - case 181: - case 178: - case 189: - case 186: - case 188: - case 93: - case 191: - case 175: - case 180: case 187: - case 209: + case 186: + case 194: + case 181: + case 179: + case 178: + case 184: + case 185: + case 183: + case 180: + case 191: + case 188: + case 190: + case 94: + case 193: + case 177: + case 182: + case 189: + case 211: return true; default: return false; } } ts.isStatement = isStatement; + function isClassElement(n) { + switch (n.kind) { + case 135: + case 132: + case 134: + case 136: + case 137: + case 140: + return true; + default: + return false; + } + } + ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 64 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 65 && name.kind !== 8 && name.kind !== 7) { return false; } - var _parent = name.parent; - if (_parent.kind === 208 || _parent.kind === 212) { - if (_parent.propertyName) { + var parent = name.parent; + if (parent.kind === 210 || parent.kind === 214) { + if (parent.propertyName) { return true; } } - if (isDeclaration(_parent)) { - return _parent.name === name; + if (isDeclaration(parent)) { + return parent.name === name; } return false; } ts.isDeclarationName = isDeclarationName; + function isAliasSymbolDeclaration(node) { + return node.kind === 205 || + node.kind === 207 && !!node.name || + node.kind === 208 || + node.kind === 210 || + node.kind === 214 || + node.kind === 211 && node.expression.kind === 65; + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassBaseTypeNode(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 78); + var heritageClause = getHeritageClause(node.heritageClauses, 79); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassBaseTypeNode = getClassBaseTypeNode; function getClassImplementedTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 102); + var heritageClause = getHeritageClause(node.heritageClauses, 103); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 78); + var heritageClause = getHeritageClause(node.heritageClauses, 79); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -3690,7 +3849,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 65 <= token && token <= 124; + return 66 <= token && token <= 125; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -3699,19 +3858,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 126 && + declaration.name.kind === 127 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 153 && isESSymbolIdentifier(node.expression); + return node.kind === 155 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 64 || name.kind === 8 || name.kind === 7) { + if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 126) { + if (name.kind === 127) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -3726,19 +3885,19 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 64 && node.text === "Symbol"; + return node.kind === 65 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 108: - case 106: - case 107: case 109: - case 77: - case 114: - case 69: - case 72: + case 107: + case 108: + case 110: + case 78: + case 115: + case 70: + case 73: return true; } return false; @@ -3854,7 +4013,7 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 200 || n.kind === 221; + return isFunctionLike(n) || n.kind === 202 || n.kind === 224; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -3869,26 +4028,6 @@ var ts; return node; } ts.createSynthesizedNode = createSynthesizedNode; - function generateUniqueName(baseName, isExistingName) { - if (baseName.charCodeAt(0) !== 95) { - baseName = "_" + baseName; - if (!isExistingName(baseName)) { - return baseName; - } - } - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var _name = baseName + i; - if (!isExistingName(_name)) { - return _name; - } - i++; - } - } - ts.generateUniqueName = generateUniqueName; function createDiagnosticCollection() { var nonFileDiagnostics = []; var fileDiagnostics = {}; @@ -3989,10 +4128,267 @@ var ts; s; } ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(sourceFile, node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; } + }; + } + ts.createTextWriter = createTextWriter; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 135 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function shouldEmitToOwnFile(sourceFile, compilerOptions) { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { + return true; + } + return false; + } + return false; + } + ts.shouldEmitToOwnFile = shouldEmitToOwnFile; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 136) { + getAccessor = accessor; + } + else if (accessor.kind === 137) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 136 || member.kind === 137) + && (member.flags & 128) === (accessor.flags & 128)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 136 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 137 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + emitLeadingSpace = true; + } + }); + } + ts.emitComments = emitComments; + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + var lineCount = ts.getLineStarts(currentSourceFile).length; + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + if (pos !== comment.pos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + if (currentLineText) { + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + } + ts.writeCommentRange = writeCommentRange; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { - var nodeConstructors = new Array(223); + var nodeConstructors = new Array(226); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -4030,249 +4426,268 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 125: + case 126: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 127: + case 128: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 128: - case 130: case 129: - case 218: - case 219: - case 193: - case 150: - return visitNodes(cbNodes, node.modifiers) || + case 132: + case 131: + case 221: + case 222: + case 195: + case 152: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 140: - case 141: - case 136: - case 137: + case 142: + case 143: case 138: - return visitNodes(cbNodes, node.modifiers) || + case 139: + case 140: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 132: - case 131: - case 133: case 134: + case 133: case 135: - case 160: - case 195: - case 161: - return visitNodes(cbNodes, node.modifiers) || + case 136: + case 137: + case 162: + case 197: + case 163: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 139: + case 141: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 142: - return visitNode(cbNode, node.exprName); - case 143: - return visitNodes(cbNodes, node.members); case 144: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 145: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 146: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.elementType); case 147: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.elementTypes); case 148: + return visitNodes(cbNodes, node.types); case 149: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 150: case 151: return visitNodes(cbNodes, node.elements); - case 152: - return visitNodes(cbNodes, node.properties); case 153: + return visitNodes(cbNodes, node.elements); + case 154: + return visitNodes(cbNodes, node.properties); + case 155: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 154: + case 156: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 155: - case 156: + case 157: + case 158: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 157: + case 159: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 158: + case 160: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 159: - return visitNode(cbNode, node.expression); - case 162: - return visitNode(cbNode, node.expression); - case 163: + case 161: return visitNode(cbNode, node.expression); case 164: return visitNode(cbNode, node.expression); case 165: + return visitNode(cbNode, node.expression); + case 166: + return visitNode(cbNode, node.expression); + case 167: return visitNode(cbNode, node.operand); - case 170: + case 172: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 166: + case 168: return visitNode(cbNode, node.operand); - case 167: + case 169: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 168: + case 170: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 171: + case 173: return visitNode(cbNode, node.expression); - case 174: - case 201: + case 176: + case 203: return visitNodes(cbNodes, node.statements); - case 221: + case 224: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 175: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 194: - return visitNodes(cbNodes, node.declarations); case 177: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 196: + return visitNodes(cbNodes, node.declarations); + case 179: return visitNode(cbNode, node.expression); - case 178: + case 180: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 179: + case 181: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 180: + case 182: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 181: + case 183: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.iterator) || visitNode(cbNode, node.statement); - case 182: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 183: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 184: - case 185: - return visitNode(cbNode, node.label); - case 186: - return visitNode(cbNode, node.expression); - case 187: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 185: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 186: + case 187: + return visitNode(cbNode, node.label); case 188: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 202: - return visitNodes(cbNodes, node.clauses); - case 214: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 215: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 189: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 190: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 204: + return visitNodes(cbNodes, node.clauses); + case 217: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 218: + return visitNodes(cbNodes, node.statements); case 191: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 192: + return visitNode(cbNode, node.expression); + case 193: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 217: + case 220: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 196: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 197: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); + case 130: + return visitNode(cbNode, node.expression); case 198: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 199: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 200: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 199: - return visitNodes(cbNodes, node.modifiers) || + case 201: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 220: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 200: - return visitNodes(cbNodes, node.modifiers) || + case 202: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 203: - return visitNodes(cbNodes, node.modifiers) || + case 205: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 204: - return visitNodes(cbNodes, node.modifiers) || + case 206: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 205: + case 207: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 206: + case 208: return visitNode(cbNode, node.name); - case 207: - case 211: + case 209: + case 213: return visitNodes(cbNodes, node.elements); - case 210: - return visitNodes(cbNodes, node.modifiers) || + case 212: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 208: - case 212: + case 210: + case 214: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 209: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 169: + case 211: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 171: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 173: + case 175: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 126: + case 127: return visitNode(cbNode, node.expression); - case 216: + case 219: return visitNodes(cbNodes, node.types); - case 213: + case 216: return visitNode(cbNode, node.expression); + case 215: + return visitNodes(cbNodes, node.decorators); } } ts.forEachChild = forEachChild; @@ -4304,29 +4719,33 @@ var ts; ; function modifierToFlag(token) { switch (token) { - case 109: return 128; - case 108: return 16; - case 107: return 64; - case 106: return 32; - case 77: return 1; - case 114: return 2; - case 69: return 8192; - case 72: return 256; + case 110: return 128; + case 109: return 16; + case 108: return 64; + case 107: return 32; + case 78: return 1; + case 115: return 2; + case 70: return 8192; + case 73: return 256; } return 0; } ts.modifierToFlag = modifierToFlag; function fixupParentReferences(sourceFile) { - var _parent = sourceFile; + // normally parent references are set during binding. However, for clients that only need + // a syntax tree, and no semantic features, then the binding process is an unnecessary + // overhead. This functions allows us to set all the parents, without all the expense of + // binding. + var parent = sourceFile; forEachChild(sourceFile, visitNode); return; function visitNode(n) { - if (n.parent !== _parent) { - n.parent = _parent; - var saveParent = _parent; - _parent = n; + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; forEachChild(n, visitNode); - _parent = saveParent; + parent = saveParent; } } } @@ -4334,7 +4753,7 @@ var ts; switch (node.kind) { case 8: case 7: - case 64: + case 65: return true; } return false; @@ -4544,7 +4963,7 @@ var ts; } ts.updateSourceFile = updateSourceFile; function isEvalOrArgumentsIdentifier(node) { - return node.kind === 64 && + return node.kind === 65 && (node.text === "eval" || node.text === "arguments"); } ts.isEvalOrArgumentsIdentifier = isEvalOrArgumentsIdentifier; @@ -4622,12 +5041,13 @@ var ts; ts.createSourceFile = createSourceFile; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } + var disallowInAndDecoratorContext = 2 | 16; var parsingContext = 0; var identifiers = {}; var identifierCount = 0; var nodeCount = 0; var token; - var sourceFile = createNode(221, 0); + var sourceFile = createNode(224, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -4673,6 +5093,19 @@ var ts; function setGeneratorParameterContext(val) { setContextFlag(val, 8); } + function setDecoratorContext(val) { + setContextFlag(val, 16); + } + function doOutsideOfContext(flags, func) { + var currentContextFlags = contextFlags & flags; + if (currentContextFlags) { + setContextFlag(false, currentContextFlags); + var result = func(); + setContextFlag(true, currentContextFlags); + return result; + } + return func(); + } function allowInAnd(func) { if (contextFlags & 2) { setDisallowInContext(false); @@ -4709,6 +5142,15 @@ var ts; } return func(); } + function doInDecoratorContext(func) { + if (contextFlags & 16) { + return func(); + } + setDecoratorContext(true); + var result = func(); + setDecoratorContext(false); + return result; + } function inYieldContext() { return (contextFlags & 4) !== 0; } @@ -4721,10 +5163,13 @@ var ts; function inDisallowInContext() { return (contextFlags & 2) !== 0; } + function inDecoratorContext() { + return (contextFlags & 16) !== 0; + } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); - var _length = scanner.getTextPos() - start; - parseErrorAtPosition(start, _length, message, arg0); + var length = scanner.getTextPos() - start; + parseErrorAtPosition(start, length, message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { var lastError = ts.lastOrUndefined(sourceFile.parseDiagnostics); @@ -4781,13 +5226,13 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 64) { + if (token === 65) { return true; } - if (token === 110 && inYieldContext()) { + if (token === 111 && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 110 : token > 100; + return inStrictModeContext() ? token > 111 : token > 101; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -4858,7 +5303,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16; + node.parserContextFlags |= 32; } return node; } @@ -4880,12 +5325,12 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(64); + var node = createNode(65); node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(64, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(65, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -4908,7 +5353,7 @@ var ts; return parseIdentifierName(); } function parseComputedPropertyName() { - var node = createNode(126); + var node = createNode(127); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -4932,17 +5377,17 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); } function nextTokenCanFollowContextualModifier() { - if (token === 69) { - return nextToken() === 76; + if (token === 70) { + return nextToken() === 77; } - if (token === 77) { + if (token === 78) { nextToken(); - if (token === 72) { + if (token === 73) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 35 && token !== 14 && canFollowModifier(); } - if (token === 72) { + if (token === 73) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -4956,7 +5401,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 68 || token === 82; + return token === 69 || token === 83; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -4971,7 +5416,7 @@ var ts; case 4: return isStartOfStatement(inErrorRecovery); case 3: - return token === 66 || token === 72; + return token === 67 || token === 73; case 5: return isStartOfTypeMember(); case 6: @@ -5010,8 +5455,8 @@ var ts; return isIdentifier(); } function isNotHeritageClauseTypeName() { - if (token === 102 || - token === 78) { + if (token === 103 || + token === 79) { return lookAhead(nextTokenIsIdentifier); } return false; @@ -5032,13 +5477,13 @@ var ts; case 20: return token === 15; case 4: - return token === 15 || token === 66 || token === 72; + return token === 15 || token === 67 || token === 73; case 8: - return token === 14 || token === 78 || token === 102; + return token === 14 || token === 79 || token === 103; case 9: return isVariableDeclaratorListTerminator(); case 16: - return token === 25 || token === 16 || token === 14 || token === 78 || token === 102; + return token === 25 || token === 16 || token === 14 || token === 79 || token === 103; case 12: return token === 17 || token === 22; case 14: @@ -5131,7 +5576,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 31; + var nodeContextFlags = node.parserContextFlags & 63; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -5177,14 +5622,14 @@ var ts; function isReusableModuleElement(node) { if (node) { switch (node.kind) { - case 204: - case 203: - case 210: - case 209: - case 196: - case 197: - case 200: + case 206: + case 205: + case 212: + case 211: + case 198: case 199: + case 202: + case 201: return true; } return isReusableStatement(node); @@ -5194,12 +5639,12 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 133: - case 138: - case 132: - case 134: case 135: - case 130: + case 140: + case 134: + case 136: + case 137: + case 132: return true; } } @@ -5208,8 +5653,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 214: - case 215: + case 217: + case 218: return true; } } @@ -5218,56 +5663,56 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 195: - case 175: - case 174: - case 178: + case 197: case 177: - case 190: - case 186: - case 188: - case 185: - case 184: - case 182: - case 183: - case 181: - case 180: - case 187: case 176: - case 191: - case 189: + case 180: case 179: case 192: + case 188: + case 190: + case 187: + case 186: + case 184: + case 185: + case 183: + case 182: + case 189: + case 178: + case 193: + case 191: + case 181: + case 194: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 220; + return node.kind === 223; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 137: + case 139: + case 133: + case 140: case 131: case 138: - case 129: - case 136: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 193) { + if (node.kind !== 195) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 128) { + if (node.kind !== 129) { return false; } var parameter = node; @@ -5336,7 +5781,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(125, entity.pos); + var node = createNode(126, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -5347,13 +5792,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(64, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(169); + var template = createNode(171); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -5366,7 +5811,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(173); + var span = createNode(175); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -5400,7 +5845,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(139); + var node = createNode(141); node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 24) { node.typeArguments = parseBracketedList(17, parseType, 24, 25); @@ -5408,15 +5853,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(142); - parseExpected(96); + var node = createNode(144); + parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(127); + var node = createNode(128); node.name = parseIdentifier(); - if (parseOptional(78)) { + if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -5440,7 +5885,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token); + return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 52; } function setModifiers(node, modifiers) { if (modifiers) { @@ -5449,7 +5894,8 @@ var ts; } } function parseParameter() { - var node = createNode(128); + var node = createNode(129); + node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); @@ -5500,8 +5946,8 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 137) { - parseExpected(87); + if (kind === 139) { + parseExpected(88); } fillSignature(51, false, false, node); parseTypeMemberSemicolon(); @@ -5539,9 +5985,9 @@ var ts; nextToken(); return token === 51 || token === 23 || token === 19; } - function parseIndexSignatureDeclaration(modifiers) { - var fullStart = modifiers ? modifiers.pos : scanner.getStartPos(); - var node = createNode(138, fullStart); + function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { + var node = createNode(140, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(15, parseParameter, 18, 19); node.type = parseTypeAnnotation(); @@ -5550,19 +5996,19 @@ var ts; } function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); - var _name = parsePropertyName(); + var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(131, fullStart); - method.name = _name; + var method = createNode(133, fullStart); + method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(129, fullStart); - property.name = _name; + var property = createNode(131, fullStart); + property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -5603,14 +6049,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(136); + return parseSignatureMember(138); case 18: return isIndexSignature() - ? parseIndexSignatureDeclaration(undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 87: + case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(137); + return parseSignatureMember(139); } case 8: case 7: @@ -5628,9 +6074,11 @@ var ts; } } function parseIndexSignatureWithModifiers() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); return isIndexSignature() - ? parseIndexSignatureDeclaration(modifiers) + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) : undefined; } function isStartOfConstructSignature() { @@ -5638,7 +6086,7 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(143); + var node = createNode(145); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -5654,12 +6102,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(145); + var node = createNode(147); node.elementTypes = parseBracketedList(18, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(147); + var node = createNode(149); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -5667,8 +6115,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 141) { - parseExpected(87); + if (kind === 143) { + parseExpected(88); } fillSignature(32, false, false, node); return finishNode(node); @@ -5679,16 +6127,16 @@ var ts; } function parseNonArrayType() { switch (token) { - case 111: - case 120: - case 118: case 112: case 121: + case 119: + case 113: + case 122: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); - case 98: + case 99: return parseTokenNode(); - case 96: + case 97: return parseTypeQuery(); case 14: return parseTypeLiteral(); @@ -5702,17 +6150,17 @@ var ts; } function isStartOfType() { switch (token) { - case 111: - case 120: - case 118: case 112: case 121: - case 98: - case 96: + case 119: + case 113: + case 122: + case 99: + case 97: case 14: case 18: case 24: - case 87: + case 88: return true; case 16: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -5728,7 +6176,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(144, type.pos); + var node = createNode(146, type.pos); node.elementType = type; type = finishNode(node); } @@ -5743,7 +6191,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(146, type.pos); + var node = createNode(148, type.pos); node.types = types; type = finishNode(node); } @@ -5763,7 +6211,7 @@ var ts; if (isIdentifier() || ts.isModifier(token)) { nextToken(); if (token === 51 || token === 23 || - token === 50 || token === 52 || + token === 50 || token === 53 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -5788,10 +6236,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(140); + return parseFunctionOrConstructorType(142); } - if (token === 87) { - return parseFunctionOrConstructorType(141); + if (token === 88) { + return parseFunctionOrConstructorType(143); } return parseUnionTypeOrHigher(); } @@ -5800,11 +6248,11 @@ var ts; } function isStartOfExpression() { switch (token) { - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: case 7: case 8: case 10: @@ -5812,22 +6260,22 @@ var ts; case 16: case 18: case 14: - case 82: - case 87: + case 83: + case 88: case 36: - case 56: + case 57: case 33: case 34: case 47: case 46: - case 73: - case 96: - case 98: + case 74: + case 97: + case 99: case 38: case 39: case 24: - case 64: - case 110: + case 65: + case 111: return true; default: if (isBinaryOperator()) { @@ -5837,26 +6285,45 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && token !== 82 && isStartOfExpression(); + return token !== 14 && token !== 83 && token !== 52 && isStartOfExpression(); } function parseExpression() { + // Expression[in]: + // AssignmentExpression[in] + // Expression[in] , AssignmentExpression[in] + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; while ((operatorToken = parseOptionalToken(23))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } + if (saveDecoratorContext) { + setDecoratorContext(true); + } return expr; } function parseInitializer(inParameter) { - if (token !== 52) { + if (token !== 53) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { return undefined; } } - parseExpected(52); + parseExpected(53); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { + // AssignmentExpression[in,yield]: + // 1) ConditionalExpression[?in,?yield] + // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] + // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] + // 4) ArrowFunctionExpression[?in,?yield] + // 5) [+Yield] YieldExpression[?In] + // + // Note: for ease of implementation we treat productions '2' and '3' as the same thing. + // (i.e. they're both BinaryExpressions with an assignment operator in it). if (isYieldExpression()) { return parseYieldExpression(); } @@ -5865,7 +6332,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 64 && token === 32) { + if (expr.kind === 65 && token === 32) { return parseSimpleArrowFunctionExpression(expr); } if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { @@ -5874,7 +6341,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 110) { + if (token === 111) { if (inYieldContext()) { return true; } @@ -5895,7 +6362,7 @@ var ts; (isIdentifier() || token === 14 || token === 18); } function parseYieldExpression() { - var node = createNode(170); + var node = createNode(172); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -5909,14 +6376,14 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(161, identifier.pos); - var parameter = createNode(128, identifier.pos); + var node = createNode(163, identifier.pos); + var parameter = createNode(129, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - parseExpected(32); + node.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(); return finishNode(node); } @@ -5931,12 +6398,11 @@ var ts; if (!arrowFunction) { return undefined; } - if (parseExpected(32) || token === 14) { - arrowFunction.body = parseArrowFunctionExpressionBody(); - } - else { - arrowFunction.body = parseIdentifier(); - } + var lastToken = token; + arrowFunction.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 32 || lastToken === 14) + ? parseArrowFunctionExpressionBody() + : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { @@ -5986,7 +6452,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(161); + var node = createNode(163); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -6000,7 +6466,7 @@ var ts; if (token === 14) { return parseFunctionBlock(false, false); } - if (isStartOfStatement(true) && !isStartOfExpressionStatement() && token !== 82) { + if (isStartOfStatement(true) && !isStartOfExpressionStatement() && token !== 83) { return parseFunctionBlock(false, true); } return parseAssignmentExpressionOrHigher(); @@ -6010,10 +6476,10 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(168, leftOperand.pos); + var node = createNode(170, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; - node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); node.colonToken = parseExpectedToken(51, false, ts.Diagnostics._0_expected, ts.tokenToString(51)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); @@ -6023,7 +6489,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 85 || t === 124; + return t === 86 || t === 125; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -6032,7 +6498,7 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 85 && inDisallowInContext()) { + if (token === 86 && inDisallowInContext()) { break; } leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); @@ -6040,7 +6506,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 85) { + if (inDisallowInContext() && token === 86) { return false; } return getBinaryOperatorPrecedence() > 0; @@ -6066,8 +6532,8 @@ var ts; case 25: case 26: case 27: + case 87: case 86: - case 85: return 7; case 40: case 41: @@ -6084,33 +6550,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(167, left.pos); + var node = createNode(169, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(165); + var node = createNode(167); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(162); + var node = createNode(164); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(163); + var node = createNode(165); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(164); + var node = createNode(166); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -6124,11 +6590,11 @@ var ts; case 38: case 39: return parsePrefixUnaryExpression(); - case 73: + case 74: return parseDeleteExpression(); - case 96: + case 97: return parseTypeOfExpression(); - case 98: + case 99: return parseVoidExpression(); case 24: return parseTypeAssertion(); @@ -6140,7 +6606,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(166, expression.pos); + var node = createNode(168, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -6149,7 +6615,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 90 + var expression = token === 91 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -6163,14 +6629,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(153, expression.pos); + var node = createNode(155, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(158); + var node = createNode(160); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -6181,15 +6647,15 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(153, expression.pos); + var propertyAccess = createNode(155, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (parseOptional(18)) { - var indexedAccess = createNode(154, expression.pos); + if (!inDecoratorContext() && parseOptional(18)) { + var indexedAccess = createNode(156, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -6203,7 +6669,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(157, expression.pos); + var tagExpression = createNode(159, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -6222,7 +6688,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(155, expression.pos); + var callExpr = createNode(157, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -6230,10 +6696,10 @@ var ts; continue; } else if (token === 16) { - var _callExpr = createNode(155, expression.pos); - _callExpr.expression = expression; - _callExpr.arguments = parseArgumentList(); - expression = finishNode(_callExpr); + var callExpr = createNode(157, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); continue; } return expression; @@ -6289,11 +6755,11 @@ var ts; case 8: case 10: return parseLiteralNode(); - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: return parseTokenNode(); case 16: return parseParenthesizedExpression(); @@ -6301,12 +6767,12 @@ var ts; return parseArrayLiteralExpression(); case 14: return parseObjectLiteralExpression(); - case 82: + case 83: return parseFunctionExpression(); - case 87: + case 88: return parseNewExpression(); case 36: - case 56: + case 57: if (reScanSlashToken() === 9) { return parseLiteralNode(); } @@ -6317,28 +6783,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(159); + var node = createNode(161); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(171); + var node = createNode(173); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(172) : + token === 23 ? createNode(174) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { - return allowInAnd(parseArgumentOrArrayLiteralElement); + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(151); + var node = createNode(153); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; @@ -6346,19 +6812,20 @@ var ts; parseExpected(19); return finishNode(node); } - function tryParseAccessorDeclaration(fullStart, modifiers) { - if (parseContextualModifier(115)) { - return parseAccessorDeclaration(134, fullStart, modifiers); + function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { + if (parseContextualModifier(116)) { + return parseAccessorDeclaration(136, fullStart, decorators, modifiers); } - else if (parseContextualModifier(119)) { - return parseAccessorDeclaration(135, fullStart, modifiers); + else if (parseContextualModifier(120)) { + return parseAccessorDeclaration(137, fullStart, decorators, modifiers); } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, modifiers); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } @@ -6368,16 +6835,16 @@ var ts; var propertyName = parsePropertyName(); var questionToken = parseOptionalToken(50); if (asteriskToken || token === 16 || token === 24) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, propertyName, questionToken); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(219, fullStart); + var shorthandDeclaration = createNode(222, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(218, fullStart); + var propertyAssignment = createNode(221, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -6386,7 +6853,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(152); + var node = createNode(154); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; @@ -6396,20 +6863,27 @@ var ts; return finishNode(node); } function parseFunctionExpression() { - var node = createNode(160); - parseExpected(82); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var node = createNode(162); + parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); fillSignature(51, !!node.asteriskToken, false, node); node.body = parseFunctionBlock(!!node.asteriskToken, false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } return finishNode(node); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(156); - parseExpected(87); + var node = createNode(158); + parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 16) { @@ -6418,7 +6892,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(174); + var node = createNode(176); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(2, checkForStrictMode, parseStatement); parseExpected(15); @@ -6431,30 +6905,37 @@ var ts; function parseFunctionBlock(allowYield, ignoreMissingOpenBrace, diagnosticMessage) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } setYieldContext(savedYieldContext); return block; } function parseEmptyStatement() { - var node = createNode(176); + var node = createNode(178); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(178); - parseExpected(83); + var node = createNode(180); + parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(75) ? parseStatement() : undefined; + node.elseStatement = parseOptional(76) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(179); - parseExpected(74); + var node = createNode(181); + parseExpected(75); node.statement = parseStatement(); - parseExpected(99); + parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6462,8 +6943,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(180); - parseExpected(99); + var node = createNode(182); + parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6472,11 +6953,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(81); + parseExpected(82); parseExpected(16); var initializer = undefined; if (token !== 22) { - if (token === 97 || token === 104 || token === 69) { + if (token === 98 || token === 105 || token === 70) { initializer = parseVariableDeclarationList(true); } else { @@ -6484,22 +6965,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(85)) { - var forInStatement = createNode(182, pos); + if (parseOptional(86)) { + var forInStatement = createNode(184, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(124)) { - var forOfStatement = createNode(183, pos); + else if (parseOptional(125)) { + var forOfStatement = createNode(185, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(181, pos); + var forStatement = createNode(183, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -6517,7 +6998,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 185 ? 65 : 70); + parseExpected(kind === 187 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -6525,8 +7006,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(186); - parseExpected(89); + var node = createNode(188); + parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -6534,8 +7015,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(187); - parseExpected(100); + var node = createNode(189); + parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6543,30 +7024,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(214); - parseExpected(66); + var node = createNode(217); + parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); node.statements = parseList(4, false, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(215); - parseExpected(72); + var node = createNode(218); + parseExpected(73); parseExpected(51); node.statements = parseList(4, false, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 66 ? parseCaseClause() : parseDefaultClause(); + return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(188); - parseExpected(91); + var node = createNode(190); + parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(202, scanner.getStartPos()); + var caseBlock = createNode(204, scanner.getStartPos()); parseExpected(14); caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); parseExpected(15); @@ -6574,26 +7055,28 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(190); - parseExpected(93); + // ThrowStatement[Yield] : + // throw [no LineTerminator here]Expression[In, ?Yield]; + var node = createNode(192); + parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(191); - parseExpected(95); + var node = createNode(193); + parseExpected(96); node.tryBlock = parseBlock(false, false); - node.catchClause = token === 67 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 80) { - parseExpected(80); + node.catchClause = token === 68 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 81) { + parseExpected(81); node.finallyBlock = parseBlock(false, false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(217); - parseExpected(67); + var result = createNode(220); + parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -6602,22 +7085,22 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(192); - parseExpected(71); + var node = createNode(194); + parseExpected(72); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 64 && parseOptional(51)) { - var labeledStatement = createNode(189, fullStart); + if (expression.kind === 65 && parseOptional(51)) { + var labeledStatement = createNode(191, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(177, fullStart); + var expressionStatement = createNode(179, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -6625,7 +7108,7 @@ var ts; } function isStartOfStatement(inErrorRecovery) { if (ts.isModifier(token)) { - var result = lookAhead(parseVariableStatementOrFunctionDeclarationWithModifiers); + var result = lookAhead(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return true; } @@ -6634,39 +7117,39 @@ var ts; case 22: return !inErrorRecovery; case 14: - case 97: - case 104: - case 82: + case 98: + case 105: case 83: - case 74: - case 99: - case 81: - case 70: - case 65: - case 89: + case 84: + case 75: case 100: - case 91: - case 93: - case 95: + case 82: case 71: - case 67: - case 80: + case 66: + case 90: + case 101: + case 92: + case 94: + case 96: + case 72: + case 68: + case 81: return true; - case 69: + case 70: var isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; - case 103: - case 68: - case 116: - case 76: - case 122: + case 104: + case 69: + case 117: + case 77: + case 123: if (isDeclarationStart()) { return false; } - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { return false; } @@ -6676,7 +7159,7 @@ var ts; } function nextTokenIsEnumKeyword() { nextToken(); - return token === 76; + return token === 77; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -6686,46 +7169,46 @@ var ts; switch (token) { case 14: return parseBlock(false, false); - case 97: - case 69: - return parseVariableStatement(scanner.getStartPos(), undefined); - case 82: - return parseFunctionDeclaration(scanner.getStartPos(), undefined); + case 98: + case 70: + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + case 83: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 22: return parseEmptyStatement(); - case 83: + case 84: return parseIfStatement(); - case 74: + case 75: return parseDoStatement(); - case 99: - return parseWhileStatement(); - case 81: - return parseForOrForInOrForOfStatement(); - case 70: - return parseBreakOrContinueStatement(184); - case 65: - return parseBreakOrContinueStatement(185); - case 89: - return parseReturnStatement(); case 100: - return parseWithStatement(); - case 91: - return parseSwitchStatement(); - case 93: - return parseThrowStatement(); - case 95: - case 67: - case 80: - return parseTryStatement(); + return parseWhileStatement(); + case 82: + return parseForOrForInOrForOfStatement(); case 71: + return parseBreakOrContinueStatement(186); + case 66: + return parseBreakOrContinueStatement(187); + case 90: + return parseReturnStatement(); + case 101: + return parseWithStatement(); + case 92: + return parseSwitchStatement(); + case 94: + return parseThrowStatement(); + case 96: + case 68: + case 81: + return parseTryStatement(); + case 72: return parseDebuggerStatement(); - case 104: + case 105: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined); + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } default: - if (ts.isModifier(token)) { - var result = tryParse(parseVariableStatementOrFunctionDeclarationWithModifiers); + if (ts.isModifier(token) || token === 52) { + var result = tryParse(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return result; } @@ -6733,25 +7216,26 @@ var ts; return parseExpressionOrLabeledStatement(); } } - function parseVariableStatementOrFunctionDeclarationWithModifiers() { + function parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers() { var start = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 69: + case 70: var nextTokenIsEnum = lookAhead(nextTokenIsEnumKeyword); if (nextTokenIsEnum) { return undefined; } - return parseVariableStatement(start, modifiers); - case 104: + return parseVariableStatement(start, decorators, modifiers); + case 105: if (!isLetDeclaration()) { return undefined; } - return parseVariableStatement(start, modifiers); - case 97: - return parseVariableStatement(start, modifiers); - case 82: - return parseFunctionDeclaration(start, modifiers); + return parseVariableStatement(start, decorators, modifiers); + case 98: + return parseVariableStatement(start, decorators, modifiers); + case 83: + return parseFunctionDeclaration(start, decorators, modifiers); } return undefined; } @@ -6764,18 +7248,18 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(172); + return createNode(174); } - var node = createNode(150); + var node = createNode(152); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(150); + var node = createNode(152); var id = parsePropertyName(); - if (id.kind === 64 && token !== 51) { + if (id.kind === 65 && token !== 51) { node.name = id; } else { @@ -6787,14 +7271,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(148); + var node = createNode(150); parseExpected(14); node.elements = parseDelimitedList(10, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(149); + var node = createNode(151); parseExpected(18); node.elements = parseDelimitedList(11, parseArrayBindingElement); parseExpected(19); @@ -6813,7 +7297,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(193); + var node = createNode(195); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -6822,21 +7306,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(194); + var node = createNode(196); switch (token) { - case 97: + case 98: break; - case 104: + case 105: node.flags |= 4096; break; - case 69: + case 70: node.flags |= 8192; break; default: ts.Debug.fail(); } nextToken(); - if (token === 124 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 125 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -6850,33 +7334,37 @@ var ts; function canFollowContextualOfKeyword() { return nextTokenIsIdentifier() && nextToken() === 17; } - function parseVariableStatement(fullStart, modifiers) { - var node = createNode(175, fullStart); + function parseVariableStatement(fullStart, decorators, modifiers) { + var node = createNode(177, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } - function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(195, fullStart); + function parseFunctionDeclaration(fullStart, decorators, modifiers) { + var node = createNode(197, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(82); + parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); fillSignature(51, !!node.asteriskToken, false, node); node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, ts.Diagnostics.or_expected); return finishNode(node); } - function parseConstructorDeclaration(pos, modifiers) { - var node = createNode(133, pos); + function parseConstructorDeclaration(pos, decorators, modifiers) { + var node = createNode(135, pos); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(113); + parseExpected(114); fillSignature(51, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, ts.Diagnostics.or_expected); return finishNode(node); } - function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(132, fullStart); + function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { + var method = createNode(134, fullStart); + method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; @@ -6885,29 +7373,34 @@ var ts; method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); return finishNode(method); } - function parsePropertyOrMethodDeclaration(fullStart, modifiers) { + function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { + var property = createNode(132, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + property.initializer = allowInAnd(parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(35); - var _name = parsePropertyName(); + var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (asteriskToken || token === 16 || token === 24) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, _name, questionToken, ts.Diagnostics.or_expected); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { - var property = createNode(130, fullStart); - setModifiers(property, modifiers); - property.name = _name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); } } function parseNonParameterInitializer() { return parseInitializer(false); } - function parseAccessorDeclaration(kind, fullStart, modifiers) { + function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); fillSignature(51, false, false, node); @@ -6916,6 +7409,9 @@ var ts; } function isClassMemberStart() { var idToken; + if (token === 52) { + return true; + } while (ts.isModifier(token)) { idToken = token; nextToken(); @@ -6931,14 +7427,14 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 119 || idToken === 115) { + if (!ts.isKeyword(idToken) || idToken === 120 || idToken === 116) { return true; } switch (token) { case 16: case 24: case 51: - case 52: + case 53: case 50: return true; default: @@ -6947,6 +7443,26 @@ var ts; } return false; } + function parseDecorators() { + var decorators; + while (true) { + var decoratorStart = getNodePos(); + if (!parseOptional(52)) { + break; + } + if (!decorators) { + decorators = []; + decorators.pos = scanner.getStartPos(); + } + var decorator = createNode(130, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } function parseModifiers() { var flags = 0; var modifiers; @@ -6971,30 +7487,40 @@ var ts; } function parseClassElement() { var fullStart = getNodePos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, modifiers); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } - if (token === 113) { - return parseConstructorDeclaration(fullStart, modifiers); + if (token === 114) { + return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { - return parseIndexSignatureDeclaration(modifiers); + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } if (isIdentifierOrKeyword() || token === 8 || token === 7 || token === 35 || token === 18) { - return parsePropertyOrMethodDeclaration(fullStart, modifiers); + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + if (decorators) { + var name_3 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_3, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } - function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(196, fullStart); + function parseClassDeclaration(fullStart, decorators, modifiers) { + var savedStrictModeContext = inStrictModeContext(); + if (languageVersion >= 2) { + setStrictModeContext(true); + } + var node = createNode(198, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(68); + parseExpected(69); node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); @@ -7007,9 +7533,14 @@ var ts; else { node.members = createMissingList(); } - return finishNode(node); + var finishedNode = finishNode(node); + setStrictModeContext(savedStrictModeContext); + return finishedNode; } function parseHeritageClauses(isClassHeritageClause) { + // ClassTail[Yield,GeneratorParameter] : See 14.5 + // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } if (isHeritageClause()) { return isClassHeritageClause && inGeneratorParameterContext() ? doOutsideOfYieldContext(parseHeritageClausesWorker) @@ -7021,8 +7552,8 @@ var ts; return parseList(19, false, parseHeritageClause); } function parseHeritageClause() { - if (token === 78 || token === 102) { - var node = createNode(216); + if (token === 79 || token === 103) { + var node = createNode(219); node.token = token; nextToken(); node.types = parseDelimitedList(8, parseTypeReference); @@ -7031,41 +7562,44 @@ var ts; return undefined; } function isHeritageClause() { - return token === 78 || token === 102; + return token === 79 || token === 103; } function parseClassMembers() { return parseList(6, false, parseClassElement); } - function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(197, fullStart); + function parseInterfaceDeclaration(fullStart, decorators, modifiers) { + var node = createNode(199, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(103); + parseExpected(104); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); node.members = parseObjectTypeMembers(); return finishNode(node); } - function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(198, fullStart); + function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { + var node = createNode(200, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(122); + parseExpected(123); node.name = parseIdentifier(); - parseExpected(52); + parseExpected(53); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(220, scanner.getStartPos()); + var node = createNode(223, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } - function parseEnumDeclaration(fullStart, modifiers) { - var node = createNode(199, fullStart); + function parseEnumDeclaration(fullStart, decorators, modifiers) { + var node = createNode(201, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(76); + parseExpected(77); node.name = parseIdentifier(); if (parseExpected(14)) { node.members = parseDelimitedList(7, parseEnumMember); @@ -7077,7 +7611,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(201, scanner.getStartPos()); + var node = createNode(203, scanner.getStartPos()); if (parseExpected(14)) { node.statements = parseList(1, false, parseModuleElement); parseExpected(15); @@ -7087,31 +7621,33 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, modifiers, flags) { - var node = createNode(200, fullStart); + function parseInternalModuleTail(fullStart, decorators, modifiers, flags) { + var node = createNode(202, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(20) - ? parseInternalModuleTail(getNodePos(), undefined, 1) + ? parseInternalModuleTail(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { - var node = createNode(200, fullStart); + function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { + var node = createNode(202, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart, modifiers) { - parseExpected(116); + function parseModuleDeclaration(fullStart, decorators, modifiers) { + parseExpected(117); return token === 8 - ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) - : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) + : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); } function isExternalModuleReference() { - return token === 117 && + return token === 118 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -7120,44 +7656,52 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 123; + token === 124; } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers) { - parseExpected(84); + function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { + parseExpected(85); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 123) { - var importEqualsDeclaration = createNode(203, fullStart); + if (token !== 23 && token !== 124) { + var importEqualsDeclaration = createNode(205, fullStart); + importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(52); + parseExpected(53); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(204, fullStart); + var importDeclaration = createNode(206, fullStart); + importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(123); + parseExpected(124); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(205, fullStart); + //ImportClause: + // ImportedDefaultBinding + // NameSpaceImport + // NamedImports + // ImportedDefaultBinding, NameSpaceImport + // ImportedDefaultBinding, NamedImports + var importClause = createNode(207, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(207); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(209); } return finishNode(importClause); } @@ -7167,8 +7711,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(213); - parseExpected(117); + var node = createNode(216); + parseExpected(118); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -7182,107 +7726,116 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(206); + var namespaceImport = createNode(208); parseExpected(35); - parseExpected(101); + parseExpected(102); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 207 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(20, kind === 209 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(212); + return parseImportOrExportSpecifier(214); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(208); + return parseImportOrExportSpecifier(210); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); - var isFirstIdentifierNameNotAnIdentifier = ts.isKeyword(token) && !isIdentifier(); - var start = scanner.getTokenPos(); + var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + var checkIdentifierStart = scanner.getTokenPos(); + var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 101) { + if (token === 102) { node.propertyName = identifierName; - parseExpected(101); - if (isIdentifier()) { - node.name = parseIdentifierName(); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - } + parseExpected(102); + checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); } else { node.name = identifierName; - if (isFirstIdentifierNameNotAnIdentifier) { - parseErrorAtPosition(start, identifierName.end - start, ts.Diagnostics.Identifier_expected); - } + } + if (kind === 210 && checkIdentifierIsKeyword) { + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } - function parseExportDeclaration(fullStart, modifiers) { - var node = createNode(210, fullStart); + function parseExportDeclaration(fullStart, decorators, modifiers) { + var node = createNode(212, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(123); + parseExpected(124); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(211); - if (parseOptional(123)) { + node.exportClause = parseNamedImportsOrExports(213); + if (parseOptional(124)) { node.moduleSpecifier = parseModuleSpecifier(); } } parseSemicolon(); return finishNode(node); } - function parseExportAssignment(fullStart, modifiers) { - var node = createNode(209, fullStart); + function parseExportAssignment(fullStart, decorators, modifiers) { + var node = createNode(211, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(52)) { + if (parseOptional(53)) { node.isExportEquals = true; + node.expression = parseAssignmentExpressionOrHigher(); } else { - parseExpected(72); + parseExpected(73); + if (parseOptional(51)) { + node.type = parseType(); + } + else { + node.expression = parseAssignmentExpressionOrHigher(); + } } - node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function isLetDeclaration() { return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); } - function isDeclarationStart() { + function isDeclarationStart(followsModifier) { switch (token) { - case 97: - case 69: - case 82: + case 98: + case 70: + case 83: return true; - case 104: + case 105: return isLetDeclaration(); - case 68: - case 103: - case 76: - case 122: - return lookAhead(nextTokenIsIdentifierOrKeyword); - case 84: - return lookAhead(nextTokenCanFollowImportKeyword); - case 116: - return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 69: + case 104: case 77: + case 123: + return lookAhead(nextTokenIsIdentifierOrKeyword); + case 85: + return lookAhead(nextTokenCanFollowImportKeyword); + case 117: + return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 78: return lookAhead(nextTokenCanFollowExportKeyword); - case 114: - case 108: - case 106: - case 107: + case 115: case 109: + case 107: + case 108: + case 110: return lookAhead(nextTokenIsDeclarationStart); + case 52: + return !followsModifier; } } function isIdentifierOrKeyword() { - return token >= 64; + return token >= 65; } function nextTokenIsIdentifierOrKeyword() { nextToken(); @@ -7299,48 +7852,56 @@ var ts; } function nextTokenCanFollowExportKeyword() { nextToken(); - return token === 52 || token === 35 || - token === 14 || token === 72 || isDeclarationStart(); + return token === 53 || token === 35 || + token === 14 || token === 73 || isDeclarationStart(true); } function nextTokenIsDeclarationStart() { nextToken(); - return isDeclarationStart(); + return isDeclarationStart(true); } function nextTokenIsAsKeyword() { - return nextToken() === 101; + return nextToken() === 102; } function parseDeclaration() { var fullStart = getNodePos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (token === 77) { + if (token === 78) { nextToken(); - if (token === 72 || token === 52) { - return parseExportAssignment(fullStart, modifiers); + if (token === 73 || token === 53) { + return parseExportAssignment(fullStart, decorators, modifiers); } if (token === 35 || token === 14) { - return parseExportDeclaration(fullStart, modifiers); + return parseExportDeclaration(fullStart, decorators, modifiers); } } switch (token) { - case 97: - case 104: + case 98: + case 105: + case 70: + return parseVariableStatement(fullStart, decorators, modifiers); + case 83: + return parseFunctionDeclaration(fullStart, decorators, modifiers); case 69: - return parseVariableStatement(fullStart, modifiers); - case 82: - return parseFunctionDeclaration(fullStart, modifiers); - case 68: - return parseClassDeclaration(fullStart, modifiers); - case 103: - return parseInterfaceDeclaration(fullStart, modifiers); - case 122: - return parseTypeAliasDeclaration(fullStart, modifiers); - case 76: - return parseEnumDeclaration(fullStart, modifiers); - case 116: - return parseModuleDeclaration(fullStart, modifiers); - case 84: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers); + return parseClassDeclaration(fullStart, decorators, modifiers); + case 104: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 123: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 77: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 117: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 85: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); default: + if (decorators) { + var node = createMissingNode(215, true, ts.Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } } @@ -7415,10 +7976,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 203 && node.moduleReference.kind === 213 - || node.kind === 204 - || node.kind === 209 - || node.kind === 210 + || node.kind === 205 && node.moduleReference.kind === 216 + || node.kind === 206 + || node.kind === 211 + || node.kind === 212 ? node : undefined; }); @@ -7427,26 +7988,26 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 153: - case 154: - case 156: case 155: + case 156: + case 158: case 157: - case 151: case 159: - case 152: - case 160: - case 64: + case 153: + case 161: + case 154: + case 162: + case 65: case 9: case 7: case 8: case 10: - case 169: - case 79: - case 88: - case 92: - case 94: - case 90: + case 171: + case 80: + case 89: + case 93: + case 95: + case 91: return true; } } @@ -7454,24 +8015,25 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 52 && token <= 63; + return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; })(ts || (ts = {})); +/// var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 197 || node.kind === 198) { + if (node.kind === 199 || node.kind === 200) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 204 || node.kind === 203) && !(node.flags & 1)) { + else if ((node.kind === 206 || node.kind === 205) && !(node.flags & 1)) { return 0; } - else if (node.kind === 201) { + else if (node.kind === 203) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -7487,7 +8049,7 @@ var ts; }); return state; } - else if (node.kind === 200) { + else if (node.kind === 202) { return getModuleInstanceState(node.body); } else { @@ -7502,7 +8064,7 @@ var ts; } ts.bindSourceFile = bindSourceFile; function bindSourceFileWorker(file) { - var _parent; + var parent; var container; var blockScopeContainer; var lastContainer; @@ -7540,10 +8102,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 200 && node.name.kind === 8) { + if (node.kind === 202 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 126) { + if (node.name.kind === 127) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -7551,22 +8113,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141: - case 133: + case 143: + case 135: return "__constructor"; - case 140: - case 136: - return "__call"; - case 137: - return "__new"; + case 142: case 138: + return "__call"; + case 139: + return "__new"; + case 140: return "__index"; - case 210: + case 212: return "__export"; - case 209: - return "default"; - case 195: - case 196: + case 211: + return node.isExportEquals ? "export=" : "default"; + case 197: + case 198: return node.flags & 256 ? "default" : undefined; } } @@ -7575,10 +8137,10 @@ var ts; } function declareSymbol(symbols, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var _name = node.flags & 256 && parent ? "default" : getDeclarationName(node); + var name = node.flags & 256 && parent ? "default" : getDeclarationName(node); var symbol; - if (_name !== undefined) { - symbol = ts.hasProperty(symbols, _name) ? symbols[_name] : (symbols[_name] = createSymbol(0, _name)); + if (name !== undefined) { + symbol = ts.hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -7590,7 +8152,7 @@ var ts; file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0, _name); + symbol = createSymbol(0, name); } } else { @@ -7598,7 +8160,7 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if (node.kind === 196 && symbol.exports) { + if (node.kind === 198 && symbol.exports) { var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { @@ -7611,18 +8173,10 @@ var ts; } return symbol; } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) - return true; - node = node.parent; - } - return false; - } function declareModuleMember(node, symbolKind, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolKind & 8388608) { - if (node.kind === 212 || (node.kind === 203 && hasExportModifier)) { + if (node.kind === 214 || (node.kind === 205 && hasExportModifier)) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); } else { @@ -7630,7 +8184,7 @@ var ts; } } else { - if (hasExportModifier || isAmbientContext(container)) { + if (hasExportModifier || container.flags & 32768) { var exportKind = (symbolKind & 107455 ? 1048576 : 0) | (symbolKind & 793056 ? 2097152 : 0) | (symbolKind & 1536 ? 4194304 : 0); @@ -7647,10 +8201,10 @@ var ts; if (symbolKind & 255504) { node.locals = {}; } - var saveParent = _parent; + var saveParent = parent; var saveContainer = container; var savedBlockScopeContainer = blockScopeContainer; - _parent = node; + parent = node; if (symbolKind & 262128) { container = node; if (lastContainer) { @@ -7659,55 +8213,84 @@ var ts; lastContainer = container; } if (isBlockScopeContainer) { - setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 221); + setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 224); } ts.forEachChild(node, bind); container = saveContainer; - _parent = saveParent; + parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 200: + case 202: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 221: + case 224: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } + case 142: + case 143: + case 138: + case 139: case 140: - case 141: + case 134: + case 133: + case 135: case 136: case 137: - case 138: - case 132: - case 131: - case 133: - case 134: - case 135: - case 195: - case 160: - case 161: + case 197: + case 162: + case 163: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 196: + case 198: if (node.flags & 128) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 143: - case 152: - case 197: + case 145: + case 154: + case 199: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 199: + case 201: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } bindChildren(node, symbolKind, isBlockScopeContainer); } + function isAmbientContext(node) { + while (node) { + if (node.flags & 2) + return true; + node = node.parent; + } + return false; + } + function hasExportDeclarations(node) { + var body = node.kind === 224 ? node : node.body; + if (body.kind === 224 || body.kind === 203) { + for (var _i = 0, _a = body.statements, _n = _a.length; _i < _n; _i++) { + var stat = _a[_i]; + if (stat.kind === 212 || stat.kind === 211) { + return true; + } + } + } + return false; + } + function setExportContextFlag(node) { + if (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 32768; + } + else { + node.flags &= ~32768; + } + } function bindModuleDeclaration(node) { + setExportContextFlag(node); if (node.name.kind === 8) { bindDeclaration(node, 512, 106639, true); } @@ -7718,23 +8301,30 @@ var ts; } else { bindDeclaration(node, 512, 106639, true); - if (state === 2) { - node.symbol.constEnumOnlyModule = true; + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; } - else if (node.symbol.constEnumOnlyModule) { - node.symbol.constEnumOnlyModule = false; + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; } } } } function bindFunctionOrConstructorType(node) { + // For a given function symbol "<...>(...) => T" we want to generate a symbol identical + // to the one we would get for: { <...>(...): T } + // + // We do that by making an anonymous type literal symbol, and then setting the function + // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable + // from an actual type literal symbol you would have gotten had you used the long form. var symbol = createSymbol(131072, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072); bindChildren(node, 131072, false); var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 140 ? "__call" : "__new"] = symbol; + typeLiteralSymbol.members[node.kind === 142 ? "__call" : "__new"] = symbol; } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { var symbol = createSymbol(symbolKind, name); @@ -7746,10 +8336,10 @@ var ts; } function bindBlockScopedVariableDeclaration(node) { switch (blockScopeContainer.kind) { - case 200: + case 202: declareModuleMember(node, 2, 107455); break; - case 221: + case 224: if (ts.isExternalModule(container)) { declareModuleMember(node, 2, 107455); break; @@ -7766,16 +8356,16 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { - node.parent = _parent; + node.parent = parent; switch (node.kind) { - case 127: + case 128: bindDeclaration(node, 262144, 530912, false); break; - case 128: + case 129: bindParameter(node); break; - case 193: - case 150: + case 195: + case 152: if (ts.isBindingPattern(node.name)) { bindChildren(node, 0, false); } @@ -7786,65 +8376,65 @@ var ts; bindDeclaration(node, 1, 107454, false); } break; - case 130: - case 129: - bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); - break; - case 218: - case 219: - bindPropertyOrMethodOrAccessor(node, 4, 107455, false); - break; - case 220: - bindPropertyOrMethodOrAccessor(node, 8, 107455, false); - break; - case 136: - case 137: - case 138: - bindDeclaration(node, 131072, 0, false); - break; case 132: case 131: - bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); + bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); break; - case 195: - bindDeclaration(node, 16, 106927, true); + case 221: + case 222: + bindPropertyOrMethodOrAccessor(node, 4, 107455, false); break; - case 133: - bindDeclaration(node, 16384, 0, true); + case 223: + bindPropertyOrMethodOrAccessor(node, 8, 107455, false); + break; + case 138: + case 139: + case 140: + bindDeclaration(node, 131072, 0, false); break; case 134: - bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); - break; - case 135: - bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); - break; - case 140: - case 141: - bindFunctionOrConstructorType(node); - break; - case 143: - bindAnonymousDeclaration(node, 2048, "__type", false); - break; - case 152: - bindAnonymousDeclaration(node, 4096, "__object", false); - break; - case 160: - case 161: - bindAnonymousDeclaration(node, 16, "__function", true); - break; - case 217: - bindCatchVariableDeclaration(node); - break; - case 196: - bindDeclaration(node, 32, 899583, false); + case 133: + bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); break; case 197: - bindDeclaration(node, 64, 792992, false); + bindDeclaration(node, 16, 106927, true); + break; + case 135: + bindDeclaration(node, 16384, 0, true); + break; + case 136: + bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); + break; + case 137: + bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); + break; + case 142: + case 143: + bindFunctionOrConstructorType(node); + break; + case 145: + bindAnonymousDeclaration(node, 2048, "__type", false); + break; + case 154: + bindAnonymousDeclaration(node, 4096, "__object", false); + break; + case 162: + case 163: + bindAnonymousDeclaration(node, 16, "__function", true); + break; + case 220: + bindCatchVariableDeclaration(node); break; case 198: - bindDeclaration(node, 524288, 793056, false); + bindDeclaration(node, 32, 899583, false); break; case 199: + bindDeclaration(node, 64, 792992, false); + break; + case 200: + bindDeclaration(node, 524288, 793056, false); + break; + case 201: if (ts.isConst(node)) { bindDeclaration(node, 128, 899967, false); } @@ -7852,16 +8442,16 @@ var ts; bindDeclaration(node, 256, 899327, false); } break; - case 200: + case 202: bindModuleDeclaration(node); break; - case 203: - case 206: + case 205: case 208: - case 212: + case 210: + case 214: bindDeclaration(node, 8388608, 8388608, false); break; - case 205: + case 207: if (node.name) { bindDeclaration(node, 8388608, 8388608, false); } @@ -7869,41 +8459,42 @@ var ts; bindChildren(node, 0, false); } break; - case 210: + case 212: if (!node.exportClause) { declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); } bindChildren(node, 0, false); break; - case 209: - if (node.expression.kind === 64) { - declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 8388608); + case 211: + if (node.expression && node.expression.kind === 65) { + declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { - declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455); + declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608); } bindChildren(node, 0, false); break; - case 221: + case 224: + setExportContextFlag(node); if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); break; } - case 174: + case 176: bindChildren(node, 0, !ts.isFunctionLike(node.parent)); break; - case 217: - case 181: - case 182: + case 220: case 183: - case 202: + case 184: + case 185: + case 204: bindChildren(node, 0, true); break; default: - var saveParent = _parent; - _parent = node; + var saveParent = parent; + parent = node; ts.forEachChild(node, bind); - _parent = saveParent; + parent = saveParent; } } function bindParameter(node) { @@ -7914,8 +8505,8 @@ var ts; bindDeclaration(node, 1, 107455, false); } if (node.flags & 112 && - node.parent.kind === 133 && - node.parent.parent.kind === 196) { + node.parent.kind === 135 && + node.parent.parent.kind === 198) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } @@ -7930,12 +8521,26 @@ var ts; } } })(ts || (ts = {})); +/// var ts; (function (ts) { var nextSymbolId = 1; var nextNodeId = 1; var nextMergeId = 1; + function getNodeId(node) { + if (!node.id) + node.id = nextNodeId++; + return node.id; + } + ts.getNodeId = getNodeId; ts.checkTime = 0; + function getSymbolId(symbol) { + if (!symbol.id) { + symbol.id = nextSymbolId++; + } + return symbol.id; + } + ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -7999,7 +8604,6 @@ var ts; var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); var globals = {}; @@ -8016,10 +8620,16 @@ var ts; var globalESSymbolType; var globalIterableType; var anyArrayType; + var globalTypedPropertyDescriptorType; + var globalClassDecoratorType; + var globalParameterDecoratorType; + var globalPropertyDecoratorType; + var globalMethodDecoratorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; var emitExtends = false; + var emitDecorate = false; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -8174,20 +8784,18 @@ var ts; function getSymbolLinks(symbol) { if (symbol.flags & 67108864) return symbol; - if (!symbol.id) - symbol.id = nextSymbolId++; - return symbolLinks[symbol.id] || (symbolLinks[symbol.id] = {}); + var id = getSymbolId(symbol); + return symbolLinks[id] || (symbolLinks[id] = {}); } function getNodeLinks(node) { - if (!node.id) - node.id = nextNodeId++; - return nodeLinks[node.id] || (nodeLinks[node.id] = {}); + var nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 221); + return ts.getAncestor(node, 224); } function isGlobalSourceFile(node) { - return node.kind === 221 && !ts.isExternalModule(node); + return node.kind === 224 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -8221,6 +8829,7 @@ var ts; var lastLocation; var propertyWithInvalidInitializer; var errorLocation = location; + var grandparent; loop: while (location) { if (location.locals && !isGlobalSourceFile(location)) { if (result = getSymbol(location.locals, name, meaning)) { @@ -8228,25 +8837,25 @@ var ts; } } switch (location.kind) { - case 221: + case 224: if (!ts.isExternalModule(location)) break; - case 200: + case 202: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (!(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 212)) { + if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 214)) { break loop; } result = undefined; } break; - case 199: + case 201: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 130: - case 129: - if (location.parent.kind === 196 && !(location.flags & 128)) { + case 132: + case 131: + if (location.parent.kind === 198 && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -8255,8 +8864,8 @@ var ts; } } break; - case 196: - case 197: + case 198: + case 199: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -8265,28 +8874,28 @@ var ts; break loop; } break; - case 126: - var grandparent = location.parent.parent; - if (grandparent.kind === 196 || grandparent.kind === 197) { + case 127: + grandparent = location.parent.parent; + if (grandparent.kind === 198 || grandparent.kind === 199) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 132: - case 131: - case 133: case 134: + case 133: case 135: - case 195: - case 161: + case 136: + case 137: + case 197: + case 163: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 160: + case 162: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -8297,6 +8906,14 @@ var ts; break loop; } break; + case 130: + if (location.parent && location.parent.kind === 129) { + location = location.parent; + } + if (location.parent && ts.isClassElement(location.parent)) { + location = location.parent; + } + break; } lastLocation = location; location = location.parent; @@ -8328,14 +8945,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 193); + var variableDeclaration = ts.getAncestor(declaration, 195); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 175 || - variableDeclaration.parent.parent.kind === 181) { + if (variableDeclaration.parent.parent.kind === 177 || + variableDeclaration.parent.parent.kind === 183) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 183 || - variableDeclaration.parent.parent.kind === 182) { + else if (variableDeclaration.parent.parent.kind === 185 || + variableDeclaration.parent.parent.kind === 184) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -8355,49 +8972,94 @@ var ts; } return false; } - function isAliasSymbolDeclaration(node) { - return node.kind === 203 || - node.kind === 205 && !!node.name || - node.kind === 206 || - node.kind === 208 || - node.kind === 212 || - node.kind === 209; + function getAnyImportSyntax(node) { + if (ts.isAliasSymbolDeclaration(node)) { + if (node.kind === 205) { + return node; + } + while (node && node.kind !== 206) { + node = node.parent; + } + return node; + } } function getDeclarationOfAliasSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return isAliasSymbolDeclaration(d) ? d : undefined; }); + return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 213) { - var moduleSymbol = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node)); - var exportAssignmentSymbol = moduleSymbol && getResolvedExportAssignmentSymbol(moduleSymbol); - return exportAssignmentSymbol || moduleSymbol; + if (node.moduleReference.kind === 216) { + return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportAssignmentSymbol = getResolvedExportAssignmentSymbol(moduleSymbol); - if (!exportAssignmentSymbol) { - error(node.name, ts.Diagnostics.External_module_0_has_no_default_export_or_export_assignment, symbolToString(moduleSymbol)); + var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, ts.Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); } - return exportAssignmentSymbol; + return exportDefaultSymbol; } } function getTargetOfNamespaceImport(node) { - return resolveExternalModuleName(node, node.parent.parent.moduleSpecifier); + var moduleSpecifier = node.parent.parent.moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + function getMemberOfModuleVariable(moduleSymbol, name) { + if (moduleSymbol.flags & 3) { + var typeAnnotation = moduleSymbol.valueDeclaration.type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { + if (valueSymbol.flags & (793056 | 1536)) { + return valueSymbol; + } + var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) + result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) + result.members = typeSymbol.members; + if (valueSymbol.exports) + result.exports = valueSymbol.exports; + return result; + } + function getExportOfModule(symbol, name) { + if (symbol.flags & 1536) { + var exports_1 = getExportsOfSymbol(symbol); + if (ts.hasProperty(exports_1, name)) { + return resolveSymbol(exports_1[name]); + } + } + } + function getPropertyOfVariable(symbol, name) { + if (symbol.flags & 3) { + var typeAnnotation = symbol.valueDeclaration.type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } } function getExternalModuleMember(node, specifier) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol) { - var _name = specifier.propertyName || specifier.name; - if (_name.text) { - var symbol = getSymbol(getExportsOfSymbol(moduleSymbol), _name.text, 107455 | 793056 | 1536); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { + var name_4 = specifier.propertyName || specifier.name; + if (name_4.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_4.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_4.text); + var symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; if (!symbol) { - error(_name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(_name)); - return; + error(name_4, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_4)); } - return symbol.flags & (107455 | 793056 | 1536) ? symbol : resolveAlias(symbol); + return symbol; } } } @@ -8410,31 +9072,34 @@ var ts; resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536); } function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793056 | 1536); + return node.expression && resolveEntityName(node.expression, 107455 | 793056 | 1536); } - function getTargetOfImportDeclaration(node) { + function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 203: - return getTargetOfImportEqualsDeclaration(node); case 205: + return getTargetOfImportEqualsDeclaration(node); + case 207: return getTargetOfImportClause(node); - case 206: - return getTargetOfNamespaceImport(node); case 208: + return getTargetOfNamespaceImport(node); + case 210: return getTargetOfImportSpecifier(node); - case 212: + case 214: return getTargetOfExportSpecifier(node); - case 209: + case 211: return getTargetOfExportAssignment(node); } } + function resolveSymbol(symbol) { + return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793056 | 1536)) ? resolveAlias(symbol) : symbol; + } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - var target = getTargetOfImportDeclaration(node); + var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -8459,10 +9124,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 209) { + if (node.kind === 211 && node.expression) { checkExpressionCached(node.expression); } - else if (node.kind === 212) { + else if (node.kind === 214) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -8472,17 +9137,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 203); + importDeclaration = ts.getAncestor(entityName, 205); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 64 && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 65 && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 64 || entityName.parent.kind === 125) { + if (entityName.kind === 65 || entityName.parent.kind === 126) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 203); + ts.Debug.assert(entityName.parent.kind === 205); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -8494,13 +9159,13 @@ var ts; return undefined; } var symbol; - if (name.kind === 64) { + if (name.kind === 65) { symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return undefined; } } - else if (name.kind === 125) { + else if (name.kind === 126) { var namespace = resolveEntityName(name.left, 1536); if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) { return undefined; @@ -8556,22 +9221,22 @@ var ts; } error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["default"]; + function resolveExternalModuleSymbol(moduleSymbol) { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; } - function getResolvedExportAssignmentSymbol(moduleSymbol) { - var symbol = getExportAssignmentSymbol(moduleSymbol); - if (symbol) { - if (symbol.flags & (107455 | 793056 | 1536)) { - return symbol; - } - if (symbol.flags & 8388608) { - return resolveAlias(symbol); - } + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { + var symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (1536 | 3))) { + error(moduleReferenceExpression, ts.Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; } + return symbol; + } + function getExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="]; } function getExportsOfSymbol(symbol) { - return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports; + return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { var links = getSymbolLinks(moduleSymbol); @@ -8585,20 +9250,12 @@ var ts; } } function getExportsForModule(moduleSymbol) { - if (compilerOptions.target < 2) { - var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - return { - "default": defaultSymbol - }; - } - } var result; var visitedSymbols = []; visit(moduleSymbol); return result || moduleSymbol.exports; function visit(symbol) { - if (!ts.contains(visitedSymbols, symbol)) { + if (symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol)) { visitedSymbols.push(symbol); if (symbol !== moduleSymbol) { if (!result) { @@ -8608,9 +9265,10 @@ var ts; } var exportStars = symbol.exports["__export"]; if (exportStars) { - ts.forEach(exportStars.declarations, function (node) { + for (var _i = 0, _a = exportStars.declarations, _n = _a.length; _i < _n; _i++) { + var node = _a[_i]; visit(resolveExternalModuleName(node, node.moduleSpecifier)); - }); + } } } } @@ -8646,7 +9304,7 @@ var ts; var members = node.members; for (var _i = 0, _n = members.length; _i < _n; _i++) { var member = members[_i]; - if (member.kind === 133 && ts.nodeIsPresent(member.body)) { + if (member.kind === 135 && ts.nodeIsPresent(member.body)) { return member; } } @@ -8704,25 +9362,25 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var _location = enclosingDeclaration; _location; _location = _location.parent) { - if (_location.locals && !isGlobalSourceFile(_location)) { - if (result = callback(_location.locals)) { + for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + if (location_1.locals && !isGlobalSourceFile(location_1)) { + if (result = callback(location_1.locals)) { return result; } } - switch (_location.kind) { - case 221: - if (!ts.isExternalModule(_location)) { + switch (location_1.kind) { + case 224: + if (!ts.isExternalModule(location_1)) { break; } - case 200: - if (result = callback(getSymbolOfNode(_location).exports)) { + case 202: + if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 196: - case 197: - if (result = callback(getSymbolOfNode(_location).members)) { + case 198: + case 199: + if (result = callback(getSymbolOfNode(location_1).members)) { return result; } break; @@ -8836,8 +9494,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 200 && declaration.name.kind === 8) || - (declaration.kind === 221 && ts.isExternalModule(declaration)); + return (declaration.kind === 202 && declaration.name.kind === 8) || + (declaration.kind === 224 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -8847,17 +9505,18 @@ var ts; return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 203 && - !(declaration.flags & 1) && - isDeclarationVisible(declaration.parent)) { + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & 1) && + isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, declaration)) { - aliasesToMakeVisible.push(declaration); + if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); } } else { - aliasesToMakeVisible = [declaration]; + aliasesToMakeVisible = [anyImportSyntax]; } return true; } @@ -8868,11 +9527,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 142) { + if (entityName.parent.kind === 144) { meaning = 107455 | 1048576; } - else if (entityName.kind === 125 || - entityName.parent.kind === 203) { + else if (entityName.kind === 126 || + entityName.parent.kind === 205) { meaning = 1536; } else { @@ -8916,10 +9575,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 147) { + while (node.kind === 149) { node = node.parent; } - if (node.kind === 198) { + if (node.kind === 200) { return getSymbolOfNode(node); } } @@ -9073,7 +9732,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 111); + writeKeyword(writer, 112); } } else { @@ -9091,7 +9750,7 @@ var ts; var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { - return declaration.parent.kind === 221 || declaration.parent.kind === 201; + return declaration.parent.kind === 224 || declaration.parent.kind === 203; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -9101,7 +9760,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 96); + writeKeyword(writer, 97); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -9135,7 +9794,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 16); } - writeKeyword(writer, 87); + writeKeyword(writer, 88); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, typeStack); if (flags & 64) { @@ -9154,10 +9813,10 @@ var ts; writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures, _d = _c.length; _b < _d; _b++) { - var _signature = _c[_b]; - writeKeyword(writer, 87); + var signature = _c[_b]; + writeKeyword(writer, 88); writeSpace(writer); - buildSignatureDisplay(_signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); writePunctuation(writer, 22); writer.writeLine(); } @@ -9166,7 +9825,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 120); + writeKeyword(writer, 121); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -9179,7 +9838,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 118); + writeKeyword(writer, 119); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -9193,12 +9852,12 @@ var ts; if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); for (var _h = 0, _j = signatures.length; _h < _j; _h++) { - var _signature_1 = signatures[_h]; + var signature = signatures[_h]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { writePunctuation(writer, 50); } - buildSignatureDisplay(_signature_1, writer, enclosingDeclaration, globalFlagsToPass, typeStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); writePunctuation(writer, 22); writer.writeLine(); } @@ -9230,7 +9889,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 78); + writeKeyword(writer, 79); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } @@ -9323,12 +9982,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 200) { + if (node.kind === 202) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 221) { + else if (node.kind === 224) { return ts.isExternalModule(node) ? node : undefined; } } @@ -9371,47 +10030,56 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 193: - case 150: - case 200: - case 196: - case 197: - case 198: + case 152: + return isDeclarationVisible(node.parent.parent); case 195: - case 199: - case 203: - var _parent = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 203 && _parent.kind !== 221 && ts.isInAmbientContext(_parent))) { - return isGlobalSourceFile(_parent) || isUsedInExportAssignment(node); + if (ts.isBindingPattern(node.name) && + !node.name.elements.length) { + return false; } - return isDeclarationVisible(_parent); - case 130: - case 129: - case 134: - case 135: + case 202: + case 198: + case 199: + case 200: + case 197: + case 201: + case 205: + var parent_2 = getDeclarationContainer(node); + if (!(ts.getCombinedNodeFlags(node) & 1) && + !(node.kind !== 205 && parent_2.kind !== 224 && ts.isInAmbientContext(parent_2))) { + return isGlobalSourceFile(parent_2); + } + return isDeclarationVisible(parent_2); case 132: case 131: + case 136: + case 137: + case 134: + case 133: if (node.flags & (32 | 64)) { return false; } - case 133: - case 137: - case 136: - case 138: - case 128: - case 201: - case 140: - case 141: - case 143: + case 135: case 139: - case 144: + case 138: + case 140: + case 129: + case 203: + case 142: + case 143: case 145: + case 141: case 146: case 147: + case 148: + case 149: return isDeclarationVisible(node.parent); - case 127: - case 221: + case 207: + case 208: + case 210: + return false; + case 128: + case 224: return true; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -9425,15 +10093,44 @@ var ts; return links.isVisible; } } + function collectLinkedAliases(node) { + var exportSymbol; + if (node.parent && node.parent.kind === 211) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === 214) { + exportSymbol = getTargetOfExportSpecifier(node.parent); + } + var result = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + function buildVisibleNodeList(declarations) { + ts.forEach(declarations, function (declaration) { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!ts.contains(result, resultNode)) { + result.push(resultNode); + } + if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { + var internalModuleReference = declaration.moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } function getRootDeclaration(node) { - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent.parent; } return node; } function getDeclarationContainer(node) { node = getRootDeclaration(node); - return node.kind === 193 ? node.parent.parent.parent : node.parent; + return node.kind === 195 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -9456,13 +10153,13 @@ var ts; return parentType; } var type; - if (pattern.kind === 148) { - var _name = declaration.propertyName || declaration.name; - type = getTypeOfPropertyOfType(parentType, _name.text) || - isNumericLiteralName(_name.text) && getIndexTypeOfType(parentType, 1) || + if (pattern.kind === 150) { + var name_5 = declaration.propertyName || declaration.name; + type = getTypeOfPropertyOfType(parentType, name_5.text) || + isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(_name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(_name)); + error(name_5, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_5)); return unknownType; } } @@ -9491,10 +10188,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 182) { + if (declaration.parent.parent.kind === 184) { return anyType; } - if (declaration.parent.parent.kind === 183) { + if (declaration.parent.parent.kind === 185) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -9503,10 +10200,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 128) { + if (declaration.kind === 129) { var func = declaration.parent; - if (func.kind === 135 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 134); + if (func.kind === 137 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 136); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -9519,7 +10216,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 219) { + if (declaration.kind === 222) { return checkIdentifier(declaration.name); } return undefined; @@ -9537,8 +10234,8 @@ var ts; var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); - var _name = e.propertyName || e.name; - var symbol = createSymbol(flags, _name.text); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); symbol.type = getTypeFromBindingElement(e); members[symbol.name] = symbol; }); @@ -9548,7 +10245,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 172 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 174 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -9556,7 +10253,7 @@ var ts; return !elementTypes.length ? anyArrayType : hasSpreadElement ? createArrayType(getUnionType(elementTypes)) : createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 148 + return pattern.kind === 150 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -9566,7 +10263,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 218 ? getWidenedType(type) : type; + return declaration.kind !== 221 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -9574,7 +10271,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 128 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 129 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -9587,11 +10284,20 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 217) { + if (declaration.parent.kind === 220) { return links.type = anyType; } - if (declaration.kind === 209) { - return links.type = checkExpression(declaration.expression); + if (declaration.kind === 211) { + var exportAssignment = declaration; + if (exportAssignment.expression) { + return links.type = checkExpression(exportAssignment.expression); + } + else if (exportAssignment.type) { + return links.type = getTypeFromTypeNode(exportAssignment.type); + } + else { + return links.type = anyType; + } } links.type = resolvingType; var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -9615,7 +10321,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 134) { + if (accessor.kind === 136) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -9634,8 +10340,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 134); - var setter = ts.getDeclarationOfKind(symbol, 135); + var getter = ts.getDeclarationOfKind(symbol, 136); + var setter = ts.getDeclarationOfKind(symbol, 137); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -9665,8 +10371,8 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var _getter = ts.getDeclarationOfKind(symbol, 134); - error(_getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + var getter = ts.getDeclarationOfKind(symbol, 136); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } } @@ -9732,7 +10438,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 197 || node.kind === 196) { + if (node.kind === 199 || node.kind === 198) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -9763,7 +10469,7 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(symbol, 196); + var declaration = ts.getDeclarationOfKind(symbol, 198); var baseTypeNode = ts.getClassBaseTypeNode(declaration); if (baseTypeNode) { var baseType = getTypeFromTypeReferenceNode(baseTypeNode); @@ -9804,7 +10510,7 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 197 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 199 && ts.getInterfaceBaseTypeNodes(declaration)) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { @@ -9835,7 +10541,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 198); + var declaration = ts.getDeclarationOfKind(symbol, 200); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -9843,8 +10549,8 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var _declaration = ts.getDeclarationOfKind(symbol, 198); - error(_declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + var declaration = ts.getDeclarationOfKind(symbol, 200); + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; } @@ -9862,7 +10568,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 127).constraint) { + if (!ts.getDeclarationOfKind(symbol, 128).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -10029,8 +10735,8 @@ var ts; return emptyArray; } } - for (var _i_1 = 1; _i_1 < signatureLists.length; _i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[_i_1])) { + for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { + if (!signatureListsIdentical(signatures, signatureLists[i_1])) { return emptyArray; } } @@ -10199,11 +10905,11 @@ var ts; var propTypes = []; var declarations = []; for (var _a = 0, _b = props.length; _a < _b; _a++) { - var _prop = props[_a]; - if (_prop.declarations) { - declarations.push.apply(declarations, _prop.declarations); + var prop = props[_a]; + if (prop.declarations) { + declarations.push.apply(declarations, prop.declarations); } - propTypes.push(getTypeOfSymbol(_prop)); + propTypes.push(getTypeOfSymbol(prop)); } var result = createSymbol(4 | 67108864 | 268435456, name); result.unionType = unionType; @@ -10240,9 +10946,9 @@ var ts; } } if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - var _symbol = getPropertyOfObjectType(globalFunctionType, name); - if (_symbol) - return _symbol; + var symbol = getPropertyOfObjectType(globalFunctionType, name); + if (symbol) + return symbol; } return getPropertyOfObjectType(globalObjectType, name); } @@ -10275,20 +10981,29 @@ var ts; }); return result; } + function symbolsToArray(symbols) { + var result = []; + for (var id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } function getExportsOfExternalModule(node) { if (!node.moduleSpecifier) { return emptyArray; } - var _module = resolveExternalModuleName(node, node.moduleSpecifier); - if (!_module || !_module.exports) { + var module = resolveExternalModuleName(node, node.moduleSpecifier); + if (!module) { return emptyArray; } - return ts.mapToArray(getExportsOfModule(_module)); + return symbolsToArray(getExportsOfModule(module)); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 133 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 135 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -10317,8 +11032,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 134 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 135); + if (declaration.kind === 136 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 137); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -10336,19 +11051,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 140: - case 141: - case 195: - case 132: - case 131: + case 142: + case 143: + case 197: + case 134: case 133: + case 135: + case 138: + case 139: + case 140: case 136: case 137: - case 138: - case 134: - case 135: - case 160: - case 161: + case 162: + case 163: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -10418,7 +11133,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 133 || signature.declaration.kind === 137; + var isConstructor = signature.declaration.kind === 135 || signature.declaration.kind === 139; var type = createObjectType(32768 | 65536); type.members = emptySymbols; type.properties = emptyArray; @@ -10432,7 +11147,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 118 : 120; + var syntaxKind = kind === 1 ? 119 : 121; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -10462,7 +11177,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 127).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 128).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -10512,13 +11227,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 127; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 128; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 139 && n.typeName.kind === 64) { + if (n.kind === 141 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -10583,9 +11298,9 @@ var ts; for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 196: - case 197: + case 198: case 199: + case 201: return declaration; } } @@ -10762,38 +11477,38 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 111: - return anyType; - case 120: - return stringType; - case 118: - return numberType; case 112: - return booleanType; + return anyType; case 121: + return stringType; + case 119: + return numberType; + case 113: + return booleanType; + case 122: return esSymbolType; - case 98: + case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 139: - return getTypeFromTypeReferenceNode(node); - case 142: - return getTypeFromTypeQueryNode(node); - case 144: - return getTypeFromArrayTypeNode(node); - case 145: - return getTypeFromTupleTypeNode(node); - case 146: - return getTypeFromUnionTypeNode(node); - case 147: - return getTypeFromTypeNode(node.type); - case 140: case 141: + return getTypeFromTypeReferenceNode(node); + case 144: + return getTypeFromTypeQueryNode(node); + case 146: + return getTypeFromArrayTypeNode(node); + case 147: + return getTypeFromTupleTypeNode(node); + case 148: + return getTypeFromUnionTypeNode(node); + case 149: + return getTypeFromTypeNode(node.type); + case 142: case 143: + case 145: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 64: - case 125: + case 65: + case 126: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -10856,6 +11571,7 @@ var ts; return function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; return getInferredType(context, i); } } @@ -10943,27 +11659,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 160: - case 161: + case 162: + case 163: return isContextSensitiveFunctionLikeDeclaration(node); - case 152: + case 154: return ts.forEach(node.properties, isContextSensitive); - case 151: + case 153: return ts.forEach(node.elements, isContextSensitive); - case 168: + case 170: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 167: + case 169: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 218: + case 221: return isContextSensitive(node.initializer); - case 132: - case 131: + case 134: + case 133: return isContextSensitiveFunctionLikeDeclaration(node); - case 159: + case 161: return isContextSensitive(node.expression); } return false; @@ -11019,6 +11735,7 @@ var ts; var expandingFlags; var depth = 0; var overflow = false; + var elaborateErrors = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); if (overflow) { @@ -11027,7 +11744,8 @@ var ts; else if (errorInfo) { if (errorInfo.next === undefined) { errorInfo = undefined; - isRelatedTo(source, target, errorNode !== undefined, headMessage, true); + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); } if (containingMessageChain) { errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); @@ -11038,9 +11756,8 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } - function isRelatedTo(source, target, reportErrors, headMessage, elaborateErrors) { - if (elaborateErrors === void 0) { elaborateErrors = false; } - var _result; + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; if (source === target) return -1; if (relation !== identityRelation) { @@ -11064,54 +11781,54 @@ var ts; if (source.flags & 16384 || target.flags & 16384) { if (relation === identityRelation) { if (source.flags & 16384 && target.flags & 16384) { - if (_result = unionTypeRelatedToUnionType(source, target)) { - if (_result &= unionTypeRelatedToUnionType(target, source)) { - return _result; + if (result = unionTypeRelatedToUnionType(source, target)) { + if (result &= unionTypeRelatedToUnionType(target, source)) { + return result; } } } else if (source.flags & 16384) { - if (_result = unionTypeRelatedToType(source, target, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; } } else { - if (_result = unionTypeRelatedToType(target, source, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(target, source, reportErrors)) { + return result; } } } else { if (source.flags & 16384) { - if (_result = unionTypeRelatedToType(source, target, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; } } else { - if (_result = typeRelatedToUnionType(source, target, reportErrors)) { - return _result; + if (result = typeRelatedToUnionType(source, target, reportErrors)) { + return result; } } } } else if (source.flags & 512 && target.flags & 512) { - if (_result = typeParameterRelatedTo(source, target, reportErrors)) { - return _result; + if (result = typeParameterRelatedTo(source, target, reportErrors)) { + return result; } } else { var saveErrorInfo = errorInfo; if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (_result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return _result; + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); if (sourceOrApparentType.flags & 48128 && target.flags & 48128 && - (_result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors, elaborateErrors))) { + (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { errorInfo = saveErrorInfo; - return _result; + return result; } } if (reportErrors) { @@ -11127,7 +11844,7 @@ var ts; return 0; } function unionTypeRelatedToUnionType(source, target) { - var _result = -1; + var result = -1; var sourceTypes = source.types; for (var _i = 0, _n = sourceTypes.length; _i < _n; _i++) { var sourceType = sourceTypes[_i]; @@ -11135,9 +11852,9 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typeRelatedToUnionType(source, target, reportErrors) { var targetTypes = target.types; @@ -11150,7 +11867,7 @@ var ts; return 0; } function unionTypeRelatedToType(source, target, reportErrors) { - var _result = -1; + var result = -1; var sourceTypes = source.types; for (var _i = 0, _n = sourceTypes.length; _i < _n; _i++) { var sourceType = sourceTypes[_i]; @@ -11158,20 +11875,20 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typesRelatedTo(sources, targets, reportErrors) { - var _result = -1; + var result = -1; for (var i = 0, len = sources.length; i < len; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typeParameterRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { @@ -11198,8 +11915,7 @@ var ts; return 0; } } - function objectTypeRelatedTo(source, target, reportErrors, elaborateErrors) { - if (elaborateErrors === void 0) { elaborateErrors = false; } + function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0; } @@ -11237,20 +11953,20 @@ var ts; expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) expandingFlags |= 2; - var _result; + var result; if (expandingFlags === 3) { - _result = 1; + result = 1; } else { - _result = propertiesRelatedTo(source, target, reportErrors); - if (_result) { - _result &= signaturesRelatedTo(source, target, 0, reportErrors); - if (_result) { - _result &= signaturesRelatedTo(source, target, 1, reportErrors); - if (_result) { - _result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (_result) { - _result &= numberIndexTypesRelatedTo(source, target, reportErrors); + result = propertiesRelatedTo(source, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(source, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(source, target, reportErrors); } } } @@ -11258,23 +11974,23 @@ var ts; } expandingFlags = saveExpandingFlags; depth--; - if (_result) { + if (result) { var maybeCache = maybeStack[depth]; - var destinationCache = (_result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; + var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; ts.copyMap(maybeCache, destinationCache); } else { relation[id] = reportErrors ? 3 : 2; } - return _result; + return result; } function isDeeplyNestedGeneric(type, stack) { if (type.flags & 4096 && depth >= 10) { - var _target = type.target; + var target_1 = type.target; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 4096 && t.target === _target) { + if (t.flags & 4096 && t.target === target_1) { count++; if (count >= 10) return true; @@ -11287,7 +12003,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var _result = -1; + var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 131072); for (var _i = 0, _n = properties.length; _i < _n; _i++) { @@ -11342,7 +12058,7 @@ var ts; } return 0; } - _result &= related; + result &= related; if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); @@ -11352,7 +12068,7 @@ var ts; } } } - return _result; + return result; } function propertiesIdenticalTo(source, target) { var sourceProperties = getPropertiesOfObjectType(source); @@ -11360,7 +12076,7 @@ var ts; if (sourceProperties.length !== targetProperties.length) { return 0; } - var _result = -1; + var result = -1; for (var _i = 0, _n = sourceProperties.length; _i < _n; _i++) { var sourceProp = sourceProperties[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); @@ -11371,9 +12087,9 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function signaturesRelatedTo(source, target, kind, reportErrors) { if (relation === identityRelation) { @@ -11384,7 +12100,7 @@ var ts; } var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); - var _result = -1; + var result = -1; var saveErrorInfo = errorInfo; outer: for (var _i = 0, _n = targetSignatures.length; _i < _n; _i++) { var t = targetSignatures[_i]; @@ -11395,7 +12111,7 @@ var ts; if (!s.hasStringLiterals || source.flags & 65536) { var related = signatureRelatedTo(s, t, localErrors); if (related) { - _result &= related; + result &= related; errorInfo = saveErrorInfo; continue outer; } @@ -11405,7 +12121,7 @@ var ts; return 0; } } - return _result; + return result; } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -11435,14 +12151,14 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - var _result = -1; + var result = -1; for (var i = 0; i < checkCount; i++) { - var _s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var _t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var s_1 = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t_1 = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - var related = isRelatedTo(_s, _t, reportErrors); + var related = isRelatedTo(s_1, t_1, reportErrors); if (!related) { - related = isRelatedTo(_t, _s, false); + related = isRelatedTo(t_1, s_1, false); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); @@ -11451,13 +12167,13 @@ var ts; } errorInfo = saveErrorInfo; } - _result &= related; + result &= related; } var t = getReturnTypeOfSignature(target); if (t === voidType) - return _result; + return result; var s = getReturnTypeOfSignature(source); - return _result & isRelatedTo(s, t, reportErrors); + return result & isRelatedTo(s, t, reportErrors); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -11465,15 +12181,15 @@ var ts; if (sourceSignatures.length !== targetSignatures.length) { return 0; } - var _result = -1; + var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function stringIndexTypesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { @@ -11593,14 +12309,14 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var _i = 0, _len = source.parameters.length; _i < _len; _i++) { - var s = source.hasRestParameter && _i === _len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[_i]); - var t = target.hasRestParameter && _i === _len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[_i]); - var _related = compareTypes(s, t); - if (!_related) { + for (var i = 0, len = source.parameters.length; i < len; i++) { + var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var related = compareTypes(s, t); + if (!related) { return 0; } - result &= _related; + result &= related; } if (compareReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); @@ -11633,6 +12349,7 @@ var ts; downfallType = types[j]; } } + ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); if (score > bestSupertypeScore) { bestSupertype = types[i]; bestSupertypeDownfallType = downfallType; @@ -11713,17 +12430,17 @@ var ts; return reportWideningErrorsInType(type.typeArguments[0]); } if (type.flags & 131072) { - var _errorReported = false; + var errorReported = false; ts.forEach(getPropertiesOfObjectType(type), function (p) { var t = getTypeOfSymbol(p); if (t.flags & 262144) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } - _errorReported = true; + errorReported = true; } }); - return _errorReported; + return errorReported; } return false; } @@ -11731,22 +12448,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 130: - case 129: + case 132: + case 131: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 128: + case 129: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 195: - case 132: - case 131: + case 197: case 134: - case 135: - case 160: - case 161: + case 133: + case 136: + case 137: + case 162: + case 163: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -11795,12 +12512,11 @@ var ts; var inferences = []; for (var _i = 0, _n = typeParameters.length; _i < _n; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined }); + inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); } return { typeParameters: typeParameters, inferUnionTypes: inferUnionTypes, - inferenceCount: 0, inferences: inferences, inferredTypes: new Array(typeParameters.length) }; @@ -11821,11 +12537,11 @@ var ts; } function isWithinDepthLimit(type, stack) { if (depth >= 5) { - var _target = type.target; + var target_2 = type.target; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 4096 && t.target === _target) { + if (t.flags & 4096 && t.target === target_2) { count++; } } @@ -11842,28 +12558,31 @@ var ts; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { var inferences = context.inferences[i]; - var candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) - candidates.push(source); - break; + if (!inferences.isFixed) { + var candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!ts.contains(candidates, source)) { + candidates.push(source); + } + } + return; } } } else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { var sourceTypes = source.typeArguments; var targetTypes = target.typeArguments; - for (var _i = 0; _i < sourceTypes.length; _i++) { - inferFromTypes(sourceTypes[_i], targetTypes[_i]); + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); } } else if (target.flags & 16384) { - var _targetTypes = target.types; + var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - for (var _a = 0, _n = _targetTypes.length; _a < _n; _a++) { - var t = _targetTypes[_a]; + for (var _i = 0, _n = targetTypes.length; _i < _n; _i++) { + var t = targetTypes[_i]; if (t.flags & 512 && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -11879,9 +12598,9 @@ var ts; } } else if (source.flags & 16384) { - var _sourceTypes = source.types; - for (var _b = 0, _c = _sourceTypes.length; _b < _c; _b++) { - var sourceType = _sourceTypes[_b]; + var sourceTypes = source.types; + for (var _a = 0, _b = sourceTypes.length; _a < _b; _a++) { + var sourceType = sourceTypes[_a]; inferFromTypes(sourceType, target); } } @@ -11945,19 +12664,25 @@ var ts; } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; + var inferenceSucceeded; if (!inferredType) { var inferences = getInferenceCandidates(context, index); if (inferences.length) { var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType; + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; } else { inferredType = emptyObjectType; + inferenceSucceeded = true; } - if (inferredType !== inferenceFailureType) { + if (inferenceSucceeded) { var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + context.failedTypeParameterIndex = index; + } context.inferredTypes[index] = inferredType; } return inferredType; @@ -11981,10 +12706,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 142: + case 144: return true; - case 64: - case 125: + case 65: + case 126: node = node.parent; continue; default: @@ -12024,12 +12749,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 52 && node.operatorToken.kind <= 63) { + if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 159) { + while (n.kind === 161) { n = n.expression; } - if (n.kind === 64 && getResolvedSymbol(n) === symbol) { + if (n.kind === 65 && getResolvedSymbol(n) === symbol) { return true; } } @@ -12043,46 +12768,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 167: + case 169: return isAssignedInBinaryExpression(node); - case 193: - case 150: - return isAssignedInVariableDeclaration(node); - case 148: - case 149: - case 151: + case 195: case 152: + return isAssignedInVariableDeclaration(node); + case 150: + case 151: case 153: case 154: case 155: case 156: + case 157: case 158: - case 159: - case 165: - case 162: - case 163: + case 160: + case 161: + case 167: case 164: + case 165: case 166: case 168: - case 171: - case 174: - case 175: + case 170: + case 173: + case 176: case 177: - case 178: case 179: case 180: case 181: case 182: case 183: - case 186: - case 187: + case 184: + case 185: case 188: - case 214: - case 215: case 189: case 190: - case 191: case 217: + case 218: + case 191: + case 192: + case 193: + case 220: return ts.forEachChild(node, isAssignedIn); } return false; @@ -12090,10 +12815,10 @@ var ts; } function resolveLocation(node) { var containerNodes = []; - for (var _parent = node.parent; _parent; _parent = _parent.parent) { - if ((ts.isExpression(_parent) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(_parent)) { - containerNodes.unshift(_parent); + for (var parent_3 = node.parent; parent_3; parent_3 = parent_3.parent) { + if ((ts.isExpression(parent_3) || ts.isObjectLiteralMethod(node)) && + isContextSensitive(parent_3)) { + containerNodes.unshift(parent_3); } } ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); @@ -12118,17 +12843,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 178: + case 180: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 168: + case 170: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 167: + case 169: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -12138,14 +12863,14 @@ var ts; } } break; - case 221: - case 200: - case 195: - case 132: - case 131: + case 224: + case 202: + case 197: case 134: - case 135: case 133: + case 136: + case 137: + case 135: break loop; } if (narrowedType !== type) { @@ -12158,12 +12883,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 163 || expr.right.kind !== 8) { + if (expr.left.kind !== 165 || expr.right.kind !== 8) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 64 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 65 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -12209,7 +12934,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (type.flags & 1 || !assumeTrue || expr.left.kind !== 64 || getResolvedSymbol(expr.left) !== symbol) { + if (type.flags & 1 || !assumeTrue || expr.left.kind !== 65 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -12231,9 +12956,9 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 159: + case 161: return narrowType(type, expr.expression, assumeTrue); - case 167: + case 169: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -12244,11 +12969,11 @@ var ts; else if (operator === 49) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 86) { + else if (operator === 87) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 165: + case 167: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -12259,7 +12984,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 161) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 163) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -12283,15 +13008,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 217) { + symbol.valueDeclaration.parent.kind === 220) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 194) { + while (container.kind !== 196) { container = container.parent; } container = container.parent; - if (container.kind === 175) { + if (container.kind === 177) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -12308,9 +13033,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 196 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 198 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 130 || container.kind === 133) { + if (container.kind === 132 || container.kind === 135) { getNodeLinks(classNode).flags |= 4; } else { @@ -12320,36 +13045,36 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 161) { + if (container.kind === 163) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 200: + case 202: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 199: + case 201: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 133: + case 135: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 130: - case 129: + case 132: + case 131: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 126: + case 127: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 196 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 198 ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -12358,15 +13083,15 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 128) { + if (n.kind === 129) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 155 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 196); + var isCallExpression = node.parent.kind === 157 && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 198); var baseClass; if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -12381,31 +13106,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 133; + canUseSuperExpression = container.kind === 135; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 161) { + while (container && container.kind === 163) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 196) { + if (container && container.parent && container.parent.kind === 198) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 132 || - container.kind === 131 || - container.kind === 134 || - container.kind === 135; + container.kind === 134 || + container.kind === 133 || + container.kind === 136 || + container.kind === 137; } else { canUseSuperExpression = - container.kind === 132 || + container.kind === 134 || + container.kind === 133 || + container.kind === 136 || + container.kind === 137 || + container.kind === 132 || container.kind === 131 || - container.kind === 134 || - container.kind === 135 || - container.kind === 130 || - container.kind === 129 || - container.kind === 133; + container.kind === 135; } } } @@ -12419,7 +13144,7 @@ var ts; getNodeLinks(node).flags |= 16; returnType = baseClass; } - if (container.kind === 133 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 135 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -12429,7 +13154,7 @@ var ts; return returnType; } } - if (container.kind === 126) { + if (container.kind === 127) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -12467,7 +13192,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 128) { + if (declaration.kind === 129) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -12482,7 +13207,7 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 133 || func.kind === 134 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 135))) { + if (func.type || func.kind === 135 || func.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 137))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } var signature = getContextualSignatureForFunctionLikeDeclaration(func); @@ -12502,7 +13227,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 157) { + if (template.parent.kind === 159) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -12510,7 +13235,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 52 && operator <= 63) { + if (operator >= 53 && operator <= 64) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } @@ -12608,35 +13333,35 @@ var ts; if (node.contextualType) { return node.contextualType; } - var _parent = node.parent; - switch (_parent.kind) { - case 193: - case 128: - case 130: + var parent = node.parent; + switch (parent.kind) { + case 195: case 129: - case 150: + case 132: + case 131: + case 152: return getContextualTypeForInitializerExpression(node); - case 161: - case 186: + case 163: + case 188: return getContextualTypeForReturnExpression(node); - case 155: - case 156: - return getContextualTypeForArgument(_parent, node); + case 157: case 158: - return getTypeFromTypeNode(_parent.type); - case 167: + return getContextualTypeForArgument(parent, node); + case 160: + return getTypeFromTypeNode(parent.type); + case 169: return getContextualTypeForBinaryOperand(node); - case 218: - return getContextualTypeForObjectLiteralElement(_parent); - case 151: + case 221: + return getContextualTypeForObjectLiteralElement(parent); + case 153: return getContextualTypeForElementExpression(node); - case 168: + case 170: return getContextualTypeForConditionalOperand(node); - case 173: - ts.Debug.assert(_parent.parent.kind === 169); - return getContextualTypeForSubstitutionExpression(_parent.parent, node); - case 159: - return getContextualType(_parent); + case 175: + ts.Debug.assert(parent.parent.kind === 171); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 161: + return getContextualType(parent); } return undefined; } @@ -12650,13 +13375,13 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 160 || node.kind === 161; + return node.kind === 162 || node.kind === 163; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -12699,15 +13424,15 @@ var ts; return mapper && mapper !== identityMapper; } function isAssignmentTarget(node) { - var _parent = node.parent; - if (_parent.kind === 167 && _parent.operatorToken.kind === 52 && _parent.left === node) { + var parent = node.parent; + if (parent.kind === 169 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (_parent.kind === 218) { - return isAssignmentTarget(_parent.parent); + if (parent.kind === 221) { + return isAssignmentTarget(parent.parent); } - if (_parent.kind === 151) { - return isAssignmentTarget(_parent); + if (parent.kind === 153) { + return isAssignmentTarget(parent); } return false; } @@ -12728,7 +13453,7 @@ var ts; var elementTypes = []; ts.forEach(elements, function (e) { var type = checkExpression(e, contextualMapper); - if (e.kind === 171) { + if (e.kind === 173) { elementTypes.push(getIndexTypeOfType(type, 1) || anyType); hasSpreadElement = true; } @@ -12745,7 +13470,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 126 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 127 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return allConstituentTypesHaveKind(checkComputedPropertyName(name), 1 | 132); @@ -12775,19 +13500,19 @@ var ts; for (var _i = 0, _a = node.properties, _n = _a.length; _i < _n; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 218 || - memberDecl.kind === 219 || + if (memberDecl.kind === 221 || + memberDecl.kind === 222 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 218) { + if (memberDecl.kind === 221) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 132) { + else if (memberDecl.kind === 134) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 219); - type = memberDecl.name.kind === 126 + ts.Debug.assert(memberDecl.kind === 222); + type = memberDecl.name.kind === 127 ? unknownType : checkExpression(memberDecl.name, contextualMapper); } @@ -12803,7 +13528,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 134 || memberDecl.kind === 135); + ts.Debug.assert(memberDecl.kind === 136 || memberDecl.kind === 137); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -12822,21 +13547,21 @@ var ts; for (var i = 0; i < propertiesArray.length; i++) { var propertyDecl = node.properties[i]; if (kind === 0 || isNumericName(propertyDecl.name)) { - var _type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, _type)) { - propTypes.push(_type); + var type = getTypeOfSymbol(propertiesArray[i]); + if (!ts.contains(propTypes, type)) { + propTypes.push(type); } } } - var _result = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= _result.flags; - return _result; + var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; + typeFlags |= result_1.flags; + return result_1; } return undefined; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 130; + return s.valueDeclaration ? s.valueDeclaration.kind : 132; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -12846,7 +13571,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 196); + var enclosingClassDeclaration = ts.getAncestor(node, 198); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -12855,7 +13580,7 @@ var ts; } return; } - if (left.kind === 90) { + if (left.kind === 91) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -12893,7 +13618,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 90 && getDeclarationKindFromSymbol(prop) !== 132) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -12905,14 +13630,14 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 153 + var left = node.kind === 155 ? node.expression : node.left; var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 90 && getDeclarationKindFromSymbol(prop) !== 132) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { return false; } else { @@ -12927,15 +13652,15 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 156 && node.parent.expression === node) { + if (node.parent.kind === 158 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); } else { - var _start = node.end - "]".length; - var _end = node.end; - grammarErrorAtPos(sourceFile, _start, _end - _start, ts.Diagnostics.Expression_expected); + var start = node.end - "]".length; + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } } var objectType = getApparentType(checkExpression(node.expression)); @@ -12950,15 +13675,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var _name = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (_name !== undefined) { - var prop = getPropertyOfType(objectType, _name); + var name_6 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_6 !== undefined) { + var prop = getPropertyOfType(objectType, name_6); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, _name, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_6, symbolToString(objectType.symbol)); return unknownType; } } @@ -13023,7 +13748,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 157) { + if (node.kind === 159) { checkExpression(node.template); } else { @@ -13048,19 +13773,19 @@ var ts; for (var _i = 0, _n = signatures.length; _i < _n; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var _parent = signature.declaration && signature.declaration.parent; + var parent_4 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && _parent === lastParent) { + if (lastParent && parent_4 === lastParent) { index++; } else { - lastParent = _parent; + lastParent = parent_4; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = _parent; + lastParent = parent_4; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -13076,7 +13801,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 171) { + if (args[i].kind === 173) { return i; } } @@ -13086,11 +13811,11 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 157) { + if (node.kind === 159) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 169) { + if (tagExpression.template.kind === 171) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -13105,7 +13830,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 156); + ts.Debug.assert(callExpression.kind === 158); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -13144,16 +13869,23 @@ var ts; }); return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature, args, excludeArgument) { + function inferTypeArguments(signature, args, excludeArgument, context) { var typeParameters = signature.typeParameters; - var context = createInferenceContext(typeParameters, false); var inferenceMapper = createInferenceMapper(context); + for (var i = 0; i < typeParameters.length; i++) { + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 172) { - var paramType = getTypeAtPosition(signature, arg.kind === 171 ? -1 : i); + if (arg.kind !== 174) { + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 157) { + if (i === 0 && args[i].parent.kind === 159) { argType = globalTemplateStringsArrayType; } else { @@ -13164,22 +13896,15 @@ var ts; } } if (excludeArgument) { - for (var _i = 0; _i < args.length; _i++) { - if (excludeArgument[_i] === false) { - var _arg = args[_i]; - var _paramType = getTypeAtPosition(signature, _arg.kind === 171 ? -1 : _i); - inferTypes(context, checkExpressionWithContextualType(_arg, _paramType, inferenceMapper), _paramType); + for (var i = 0; i < args.length; i++) { + if (excludeArgument[i] === false) { + var arg = args[i]; + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); + inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); } } } - var inferredTypes = getInferredTypes(context); - context.failedTypeParameterIndex = ts.indexOf(inferredTypes, inferenceFailureType); - for (var _i_1 = 0; _i_1 < inferredTypes.length; _i_1++) { - if (inferredTypes[_i_1] === inferenceFailureType) { - inferredTypes[_i_1] = unknownType; - } - } - return context; + getInferredTypes(context); } function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { var typeParameters = signature.typeParameters; @@ -13200,9 +13925,9 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 172) { - var paramType = getTypeAtPosition(signature, arg.kind === 171 ? -1 : i); - var argType = i === 0 && node.kind === 157 ? globalTemplateStringsArrayType : + if (arg.kind !== 174) { + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); + var argType = i === 0 && node.kind === 159 ? globalTemplateStringsArrayType : arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { @@ -13214,10 +13939,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 157) { + if (node.kind === 159) { var template = node.template; args = [template]; - if (template.kind === 169) { + if (template.kind === 171) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -13229,8 +13954,8 @@ var ts; return args; } function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 90) { - var containingClass = ts.getAncestor(callExpression, 196); + if (callExpression.expression.kind === 91) { + var containingClass = ts.getAncestor(callExpression, 198); var baseClassTypeNode = containingClass && ts.getClassBaseTypeNode(containingClass); return baseClassTypeNode && baseClassTypeNode.typeArguments; } @@ -13239,11 +13964,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 157; + var isTaggedTemplate = node.kind === 159; var typeArguments; if (!isTaggedTemplate) { typeArguments = getEffectiveTypeArguments(node); - if (node.expression.kind !== 90) { + if (node.expression.kind !== 91) { ts.forEach(typeArguments, checkSourceElement); } } @@ -13307,56 +14032,57 @@ var ts; } return resolveErrorCall(node); function chooseOverload(candidates, relation) { - for (var _a = 0, _b = candidates.length; _a < _b; _a++) { - var current = candidates[_a]; - if (!hasCorrectArity(node, args, current)) { + for (var _i = 0, _n = candidates.length; _i < _n; _i++) { + var originalCandidate = candidates[_i]; + if (!hasCorrectArity(node, args, originalCandidate)) { continue; } - var originalCandidate = current; - var inferenceResult = void 0; - var _candidate = void 0; + var candidate = void 0; var typeArgumentsAreValid = void 0; + var inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, false) + : undefined; while (true) { - _candidate = originalCandidate; - if (_candidate.typeParameters) { + candidate = originalCandidate; + if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = new Array(_candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(_candidate, typeArguments, typeArgumentTypes, false); + typeArgumentTypes = new Array(candidate.typeParameters.length); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { - inferenceResult = inferTypeArguments(_candidate, args, excludeArgument); - typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0; - typeArgumentTypes = inferenceResult.inferredTypes; + inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; } if (!typeArgumentsAreValid) { break; } - _candidate = getSignatureInstantiation(_candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, _candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; if (index < 0) { - return _candidate; + return candidate; } excludeArgument[index] = false; } if (originalCandidate.typeParameters) { - var instantiatedCandidate = _candidate; + var instantiatedCandidate = candidate; if (typeArgumentsAreValid) { candidateForArgumentError = instantiatedCandidate; } else { candidateForTypeArgumentError = originalCandidate; if (!typeArguments) { - resultOfFailedInference = inferenceResult; + resultOfFailedInference = inferenceContext; } } } else { - ts.Debug.assert(originalCandidate === _candidate); + ts.Debug.assert(originalCandidate === candidate); candidateForArgumentError = originalCandidate; } } @@ -13364,7 +14090,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 90) { + if (node.expression.kind === 91) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1), candidatesOutArray); @@ -13448,13 +14174,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 155) { + if (node.kind === 157) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 156) { + else if (node.kind === 158) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 157) { + else if (node.kind === 159) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -13466,15 +14192,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 90) { + if (node.expression.kind === 91) { return voidType; } - if (node.kind === 156) { + if (node.kind === 158) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 133 && - declaration.kind !== 137 && - declaration.kind !== 141) { + declaration.kind !== 135 && + declaration.kind !== 139 && + declaration.kind !== 143) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -13515,9 +14241,9 @@ var ts; links.type = instantiateType(getTypeAtPosition(context, i), mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - var _parameter = signature.parameters[signature.parameters.length - 1]; - var _links = getSymbolLinks(_parameter); - _links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); + var parameter = signature.parameters[signature.parameters.length - 1]; + var links = getSymbolLinks(parameter); + links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); } } function getReturnTypeFromBody(func, contextualMapper) { @@ -13526,7 +14252,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 174) { + if (func.body.kind !== 176) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -13564,7 +14290,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 190); + return (body.statements.length === 1) && (body.statements[0].kind === 192); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -13573,7 +14299,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 174) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 176) { return; } var bodyBlock = func.body; @@ -13586,9 +14312,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 160) { + if (!hasGrammarError && node.kind === 162) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -13616,19 +14342,19 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 132 && node.kind !== 131) { + if (produceDiagnostics && node.kind !== 134 && node.kind !== 133) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } if (node.body) { - if (node.body.kind === 174) { + if (node.body.kind === 176) { checkSourceElement(node.body); } else { @@ -13654,17 +14380,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 64: { + case 65: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 153: { - var _symbol = findSymbol(n); - return !_symbol || _symbol === unknownSymbol || (_symbol.flags & ~8) !== 0; + case 155: { + var symbol = findSymbol(n); + return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 154: + case 156: return true; - case 159: + case 161: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -13672,27 +14398,40 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 64: - case 153: { + case 65: + case 155: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 154: { + case 156: { var index = n.argumentExpression; - var _symbol = findSymbol(n.expression); - if (_symbol && index && index.kind === 8) { - var _name = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(_symbol), _name); + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 8) { + var name_7 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_7); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 8192) !== 0; } return false; } - case 159: + case 161: return isConstVariableReference(n.expression); default: return false; } } + function isImportedNameFromExternalModule(n) { + switch (n.kind) { + case 156: + case 155: { + var symbol = findSymbol(n.expression); + return symbol && symbol.flags & 8388608 && isExternalModuleSymbol(resolveAlias(symbol)); + } + case 161: + return isImportedNameFromExternalModule(n.expression); + default: + return false; + } + } if (!isReferenceOrErrorExpression(n)) { error(n, invalidReferenceMessage); return false; @@ -13701,10 +14440,13 @@ var ts; error(n, constantVariableMessage); return false; } + if (isImportedNameFromExternalModule(n)) { + error(n, invalidReferenceMessage); + } return true; } function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 && node.expression.kind === 64) { + if (node.parserContextFlags & 1 && node.expression.kind === 65) { grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); } var operandType = checkExpression(node.expression); @@ -13812,17 +14554,17 @@ var ts; var properties = node.properties; for (var _i = 0, _n = properties.length; _i < _n; _i++) { var p = properties[_i]; - if (p.kind === 218 || p.kind === 219) { - var _name = p.name; + if (p.kind === 221 || p.kind === 222) { + var name_8 = p.name; var type = sourceType.flags & 1 ? sourceType : - getTypeOfPropertyOfType(sourceType, _name.text) || - isNumericLiteralName(_name.text) && getIndexTypeOfType(sourceType, 1) || + getTypeOfPropertyOfType(sourceType, name_8.text) || + isNumericLiteralName(name_8.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || _name, type); + checkDestructuringAssignment(p.initializer || name_8, type); } else { - error(_name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(_name)); + error(name_8, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_8)); } } else { @@ -13839,8 +14581,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 172) { - if (e.kind !== 171) { + if (e.kind !== 174) { + if (e.kind !== 173) { var propName = "" + i; var type = sourceType.flags & 1 ? sourceType : isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) : @@ -13870,14 +14612,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 167 && target.operatorToken.kind === 52) { + if (target.kind === 169 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 152) { + if (target.kind === 154) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 151) { + if (target.kind === 153) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -13894,32 +14636,32 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operatorToken.kind; - if (operator === 52 && (node.left.kind === 152 || node.left.kind === 151)) { + if (operator === 53 && (node.left.kind === 154 || node.left.kind === 153)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { case 35: - case 55: - case 36: case 56: - case 37: + case 36: case 57: - case 34: - case 54: - case 40: + case 37: case 58: - case 41: + case 34: + case 55: + case 40: case 59: - case 42: + case 41: case 60: - case 44: - case 62: - case 45: - case 63: - case 43: + case 42: case 61: + case 44: + case 63: + case 45: + case 64: + case 43: + case 62: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -13939,7 +14681,7 @@ var ts; } return numberType; case 33: - case 53: + case 54: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -13963,7 +14705,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 53) { + if (operator === 54) { checkAssignmentOperator(resultType); } return resultType; @@ -13982,15 +14724,15 @@ var ts; reportOperatorError(); } return booleanType; - case 86: + case 87: return checkInstanceOfExpression(node, leftType, rightType); - case 85: + case 86: return checkInExpression(node, leftType, rightType); case 48: return rightType; case 49: return getUnionType([leftType, rightType]); - case 52: + case 53: checkAssignmentOperator(rightType); return rightType; case 23: @@ -14009,20 +14751,20 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 44: - case 62: + case 63: return 49; case 45: - case 63: + case 64: return 31; case 43: - case 61: + case 62: return 48; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 52 && operator <= 63) { + if (produceDiagnostics && operator >= 53 && operator <= 64) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -14068,14 +14810,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -14101,7 +14843,7 @@ var ts; } function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 125) { + if (node.kind == 126) { type = checkQualifiedName(node); } else { @@ -14109,9 +14851,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 153 && node.parent.expression === node) || - (node.parent.kind === 154 && node.parent.expression === node) || - ((node.kind === 64 || node.kind === 125) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 155 && node.parent.expression === node) || + (node.parent.kind === 156 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 126) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -14124,65 +14866,65 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 64: + case 65: return checkIdentifier(node); - case 92: + case 93: return checkThisExpression(node); - case 90: + case 91: return checkSuperExpression(node); - case 88: + case 89: return nullType; - case 94: - case 79: + case 95: + case 80: return booleanType; case 7: return checkNumericLiteral(node); - case 169: + case 171: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 151: - return checkArrayLiteral(node, contextualMapper); - case 152: - return checkObjectLiteral(node, contextualMapper); case 153: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 154: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 155: + return checkPropertyAccessExpression(node); case 156: - return checkCallExpression(node); + return checkIndexedAccess(node); case 157: - return checkTaggedTemplateExpression(node); case 158: - return checkTypeAssertion(node); + return checkCallExpression(node); case 159: - return checkExpression(node.expression, contextualMapper); + return checkTaggedTemplateExpression(node); case 160: + return checkTypeAssertion(node); case 161: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 163: - return checkTypeOfExpression(node); + return checkExpression(node.expression, contextualMapper); case 162: - return checkDeleteExpression(node); - case 164: - return checkVoidExpression(node); + case 163: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 165: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 164: + return checkDeleteExpression(node); case 166: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 167: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 168: - return checkConditionalExpression(node, contextualMapper); - case 171: - return checkSpreadElementExpression(node, contextualMapper); - case 172: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 169: + return checkBinaryExpression(node, contextualMapper); case 170: + return checkConditionalExpression(node, contextualMapper); + case 173: + return checkSpreadElementExpression(node, contextualMapper); + case 174: + return undefinedType; + case 172: checkYieldExpression(node); return unknownType; } @@ -14199,12 +14941,18 @@ var ts; } } function checkParameter(node) { - checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + // Grammar checking + // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the + // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code + // or if its FunctionBody is strict code(11.1.5). + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 133 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 135 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -14218,12 +14966,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 138) { + if (node.kind === 140) { checkGrammarIndexSignature(node); } - else if (node.kind === 140 || node.kind === 195 || node.kind === 141 || - node.kind === 136 || node.kind === 133 || - node.kind === 137) { + else if (node.kind === 142 || node.kind === 197 || node.kind === 143 || + node.kind === 138 || node.kind === 135 || + node.kind === 139) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -14235,10 +14983,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 137: + case 139: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 136: + case 138: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -14247,7 +14995,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 197) { + if (node.kind === 199) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14262,7 +15010,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 120: + case 121: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -14270,7 +15018,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 118: + case 119: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -14284,7 +15032,7 @@ var ts; } } function checkPropertyDeclaration(node) { - checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); } function checkMethodDeclaration(node) { @@ -14307,30 +15055,30 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 155 && n.expression.kind === 90; + return n.kind === 157 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 160: - case 195: - case 161: - case 152: return false; + case 162: + case 197: + case 163: + case 154: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 92) { + if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 160 && n.kind !== 195) { + else if (n.kind !== 162 && n.kind !== 197) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 130 && + return n.kind === 132 && !(n.flags & 128) && !!n.initializer; } @@ -14340,7 +15088,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 177 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 179 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -14356,13 +15104,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 134) { + if (node.kind === 136) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 134 ? 135 : 134; + var otherKind = node.kind === 136 ? 137 : 136; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -14381,6 +15129,9 @@ var ts; } checkFunctionLikeDeclaration(node); } + function checkMissingDeclaration(node) { + checkDecorators(node); + } function checkTypeReference(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReferenceNode(node); @@ -14436,9 +15187,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 197) { - ts.Debug.assert(signatureDeclarationNode.kind === 136 || signatureDeclarationNode.kind === 137); - var signatureKind = signatureDeclarationNode.kind === 136 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 199) { + ts.Debug.assert(signatureDeclarationNode.kind === 138 || signatureDeclarationNode.kind === 139); + var signatureKind = signatureDeclarationNode.kind === 138 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -14456,7 +15207,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 197 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 199 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -14527,16 +15278,16 @@ var ts; }); if (subsequentNode) { if (subsequentNode.kind === node.kind) { - var _errorNode = subsequentNode.name || subsequentNode; + var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 132 || node.kind === 131); + ts.Debug.assert(node.kind === 134 || node.kind === 133); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; - error(_errorNode, diagnostic); + error(errorNode_1, diagnostic); return; } else if (ts.nodeIsPresent(subsequentNode.body)) { - error(_errorNode, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); + error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); return; } } @@ -14556,11 +15307,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 197 || node.parent.kind === 143 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 199 || node.parent.kind === 145 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 195 || node.kind === 132 || node.kind === 131 || node.kind === 133) { + if (node.kind === 197 || node.kind === 134 || node.kind === 133 || node.kind === 135) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -14657,16 +15408,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 197: + case 199: return 2097152; - case 200: + case 202: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 196: - case 199: + case 198: + case 201: return 2097152 | 1048576; - case 203: + case 205: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -14676,6 +15427,49 @@ var ts; } } } + function checkDecorator(node) { + var expression = node.expression; + var exprType = checkExpression(expression); + switch (node.parent.kind) { + case 198: + var classSymbol = getSymbolOfNode(node.parent); + var classConstructorType = getTypeOfSymbol(classSymbol); + var classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + checkTypeAssignableTo(exprType, classDecoratorType, node); + break; + case 132: + checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + break; + case 134: + case 136: + case 137: + var methodType = getTypeOfNode(node.parent); + var methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + checkTypeAssignableTo(exprType, methodDecoratorType, node); + break; + case 129: + checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + break; + } + } + function checkDecorators(node) { + if (!node.decorators) { + return; + } + switch (node.kind) { + case 198: + case 134: + case 136: + case 137: + case 132: + case 129: + emitDecorate = true; + break; + default: + return; + } + ts.forEach(node.decorators, checkDecorator); + } function checkFunctionDeclaration(node) { if (produceDiagnostics) { checkFunctionLikeDeclaration(node) || @@ -14688,8 +15482,9 @@ var ts; } } function checkFunctionLikeDeclaration(node) { + checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 126) { + if (node.name && node.name.kind === 127) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -14714,11 +15509,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 174) { + if (node.kind === 176) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 201) { + if (ts.isFunctionBlock(node) || node.kind === 203) { checkFunctionExpressionBodies(node); } } @@ -14736,19 +15531,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 130 || - node.kind === 129 || - node.kind === 132 || + if (node.kind === 132 || node.kind === 131 || node.kind === 134 || - node.kind === 135) { + node.kind === 133 || + node.kind === 136 || + node.kind === 137) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = getRootDeclaration(node); - if (root.kind === 128 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 129 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -14762,8 +15557,8 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var _isDeclaration = node.kind !== 64; - if (_isDeclaration) { + var isDeclaration_1 = node.kind !== 65; + if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { @@ -14778,13 +15573,13 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 196); + var enclosingClass = ts.getAncestor(node, 198); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } if (ts.getClassBaseTypeNode(enclosingClass)) { - var _isDeclaration = node.kind !== 64; - if (_isDeclaration) { + var isDeclaration_2 = node.kind !== 65; + if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -14796,56 +15591,65 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 200 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 202 && ts.getModuleInstanceState(node) !== 1) { return; } - var _parent = getDeclarationContainer(node); - if (_parent.kind === 221 && ts.isExternalModule(_parent)) { + var parent = getDeclarationContainer(node); + if (parent.kind === 224 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkVarDeclaredNamesNotShadowed(node) { - if (node.initializer && (ts.getCombinedNodeFlags(node) & 12288) === 0) { - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); - if (localDeclarationSymbol && - localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 194); - var container = varDeclList.parent.kind === 175 && - varDeclList.parent.parent; - var namesShareScope = container && - (container.kind === 174 && ts.isFunctionLike(container.parent) || - (container.kind === 201 && container.kind === 200) || - container.kind === 221); - if (!namesShareScope) { - var _name = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, _name, _name); - } + // - ScriptBody : StatementList + // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList + // also occurs in the VarDeclaredNames of StatementList. + if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || isParameterDeclaration(node)) { + return; + } + if (node.kind === 195 && !node.initializer) { + return; + } + var symbol = getSymbolOfNode(node); + if (symbol.flags & 1) { + var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); + if (localDeclarationSymbol && + localDeclarationSymbol !== symbol && + localDeclarationSymbol.flags & 2) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 196); + var container = varDeclList.parent.kind === 177 && varDeclList.parent.parent + ? varDeclList.parent.parent + : undefined; + var namesShareScope = container && + (container.kind === 176 && ts.isFunctionLike(container.parent) || + container.kind === 203 || + container.kind === 202 || + container.kind === 224); + if (!namesShareScope) { + var name_9 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_9, name_9); } } } } } function isParameterDeclaration(node) { - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent.parent; } - return node.kind === 128; + return node.kind === 129; } function checkParameterInitializer(node) { - if (getRootDeclaration(node).kind !== 128) { + if (getRootDeclaration(node).kind !== 129) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 64) { + if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 128) { + if (referencedSymbol.valueDeclaration.kind === 129) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -14863,8 +15667,9 @@ var ts; } } function checkVariableLikeDeclaration(node) { + checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -14873,7 +15678,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && getRootDeclaration(node).kind === 128 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && getRootDeclaration(node).kind === 129 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -14901,9 +15706,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 130 && node.kind !== 129) { + if (node.kind !== 132 && node.kind !== 131) { checkExportsOnMergedDeclarations(node); - if (node.kind === 193 || node.kind === 150) { + if (node.kind === 195 || node.kind === 152) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -14920,7 +15725,7 @@ var ts; return checkVariableLikeDeclaration(node); } function checkVariableStatement(node) { - checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + checkGrammarDecorators(node) || checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) { @@ -14932,7 +15737,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 174 || node.kind === 152) { + if (node.kind === 176 || node.kind === 154) { return true; } node = node.parent; @@ -14960,12 +15765,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 194) { + if (node.initializer && node.initializer.kind == 196) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -14980,13 +15785,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 151 || varExpr.kind === 152) { + if (varExpr.kind === 153 || varExpr.kind === 154) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -15001,7 +15806,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -15011,7 +15816,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 151 || varExpr.kind === 152) { + if (varExpr.kind === 153 || varExpr.kind === 154) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!allConstituentTypesHaveKind(leftType, 1 | 258)) { @@ -15051,6 +15856,31 @@ var ts; } return iteratedType; function getIteratedType(iterable, expressionForError) { + // We want to treat type as an iterable, and get the type it is an iterable of. The iterable + // must have the following structure (annotated with the names of the variables below): + // + // { // iterable + // [Symbol.iterator]: { // iteratorFunction + // (): { // iterator + // next: { // iteratorNextFunction + // (): { // iteratorNextResult + // value: T // iteratorNextValue + // } + // } + // } + // } + // } + // + // T is the type we are after. At every level that involves analyzing return types + // of signatures, we union the return types of all the signatures. + // + // Another thing to note is that at any step of this process, we could run into a dead end, + // meaning either the property is missing, or we run into the anyType. If either of these things + // happens, we return undefined to signal that we could not find the iterated type. If a property + // is missing, and the previous step did not result in 'any', then we also give an error if the + // caller requested it. Then the caller can decide what to do in the case where there is no iterated + // type. This is different from returning anyType, because that would signify that we have matched the + // whole pattern and that T (above) is 'any'. if (allConstituentTypesHaveKind(iterable, 1)) { return undefined; } @@ -15130,7 +15960,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 134 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 135))); + return !!(node.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 137))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -15144,11 +15974,11 @@ var ts; if (func) { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); var exprType = checkExpressionCached(node.expression); - if (func.kind === 135) { + if (func.kind === 137) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - if (func.kind === 133) { + if (func.kind === 135) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -15175,7 +16005,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 215 && !hasDuplicateDefaultClause) { + if (clause.kind === 218 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -15187,7 +16017,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 214) { + if (produceDiagnostics && clause.kind === 217) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -15204,7 +16034,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 189 && current.label.text === node.label.text) { + if (current.kind === 191 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -15230,7 +16060,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 64) { + if (catchClause.variableDeclaration.name.kind !== 65) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -15268,7 +16098,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 196) { + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 198) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members, _n = _a.length; _i < _n; _i++) { var member = _a[_i]; @@ -15298,22 +16128,22 @@ var ts; if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { return; } - var _errorNode; - if (prop.valueDeclaration.name.kind === 126 || prop.parent === containingType.symbol) { - _errorNode = prop.valueDeclaration; + var errorNode; + if (prop.valueDeclaration.name.kind === 127 || prop.parent === containingType.symbol) { + errorNode = prop.valueDeclaration; } else if (indexDeclaration) { - _errorNode = indexDeclaration; + errorNode = indexDeclaration; } else if (containingType.flags & 2048) { var someBaseClassHasBothPropertyAndIndexer = ts.forEach(containingType.baseTypes, function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - _errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; } - if (_errorNode && !isTypeAssignableTo(propertyType, indexType)) { + if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(_errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); } } } @@ -15345,6 +16175,7 @@ var ts; } function checkClassDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); + checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); @@ -15401,6 +16232,19 @@ var ts; return s.flags & 16777216 ? getSymbolLinks(s).target : s; } function checkKindsOfPropertyMemberOverrides(type, baseType) { + // TypeScript 1.0 spec (April 2014): 8.2.3 + // A derived class inherits all members from its base class it doesn't override. + // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. + // Both public and private property members are inherited, but only public property members can be overridden. + // A property member in a derived class is said to override a property member in a base class + // when the derived class property member has the same name and kind(instance or static) + // as the base class property member. + // The type of an overriding property member must be assignable(section 3.8.4) + // to the type of the overridden property member, or otherwise a compile - time error occurs. + // Base class instance member functions can be overridden by derived class instance member functions, + // but not by other kinds of members. + // Base class instance member variables and accessors can be overridden by + // derived class instance member variables and accessors, but not by other kinds of members. var baseProperties = getPropertiesOfObjectType(baseType); for (var _i = 0, _n = baseProperties.length; _i < _n; _i++) { var baseProperty = baseProperties[_i]; @@ -15445,7 +16289,7 @@ var ts; } } function isAccessor(kind) { - return kind === 134 || kind === 135; + return kind === 136 || kind === 137; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -15504,13 +16348,13 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 197); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 199); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15533,25 +16377,25 @@ var ts; } } function checkTypeAliasDeclaration(node) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); } function computeEnumMemberValues(node) { - var _nodeLinks = getNodeLinks(node); - if (!(_nodeLinks.flags & 128)) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 128)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 126 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 127 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); + autoValue = getConstantValueForEnumMemberInitializer(initializer); if (autoValue === undefined) { if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); @@ -15576,13 +16420,13 @@ var ts; getNodeLinks(member).enumMemberValue = autoValue++; } }); - _nodeLinks.flags |= 128; + nodeLinks.flags |= 128; } - function getConstantValueForEnumMemberInitializer(initializer, enumIsConst) { + function getConstantValueForEnumMemberInitializer(initializer) { return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 165: + case 167: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -15590,13 +16434,10 @@ var ts; switch (e.operator) { case 33: return value; case 34: return -value; - case 47: return enumIsConst ? ~value : undefined; + case 47: return ~value; } return undefined; - case 167: - if (!enumIsConst) { - return undefined; - } + case 169: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -15621,43 +16462,54 @@ var ts; return undefined; case 7: return +e.text; - case 159: - return enumIsConst ? evalConstant(e.expression) : undefined; - case 64: - case 154: - case 153: - if (!enumIsConst) { - return undefined; - } + case 161: + return evalConstant(e.expression); + case 65: + case 156: + case 155: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var _enumType; + var enumType; var propertyName; - if (e.kind === 64) { - _enumType = currentType; + if (e.kind === 65) { + enumType = currentType; propertyName = e.text; } else { - if (e.kind === 154) { + var expression; + if (e.kind === 156) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; } - _enumType = getTypeOfNode(e.expression); + expression = e.expression; propertyName = e.argumentExpression.text; } else { - _enumType = getTypeOfNode(e.expression); + expression = e.expression; propertyName = e.name.text; } - if (_enumType !== currentType) { + var current = expression; + while (current) { + if (current.kind === 65) { + break; + } + else if (current.kind === 155) { + current = current.expression; + } + else { + return undefined; + } + } + enumType = checkExpression(expression); + if (!(enumType.symbol && (enumType.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(_enumType, propertyName); + var property = getPropertyOfObjectType(enumType, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -15677,7 +16529,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -15696,7 +16548,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 199) { + if (declaration.kind !== 201) { return false; } var enumDeclaration = declaration; @@ -15719,7 +16571,7 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 196 || (declaration.kind === 195 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 198 || (declaration.kind === 197 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -15727,7 +16579,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarModifiers(node)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -15762,7 +16614,7 @@ var ts; checkSourceElement(node.body); } function getFirstIdentifier(node) { - while (node.kind === 125) { + while (node.kind === 126) { node = node.left; } return node; @@ -15773,9 +16625,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 201 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 221 && !inAmbientExternalModule) { - error(moduleName, node.kind === 210 ? + var inAmbientExternalModule = node.parent.kind === 203 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 224 && !inAmbientExternalModule) { + error(moduleName, node.kind === 212 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module : ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); return false; @@ -15794,7 +16646,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 212 ? + var message = node.kind === 214 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -15807,7 +16659,7 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -15817,7 +16669,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { checkImportBinding(importClause.namedBindings); } else { @@ -15828,7 +16680,7 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -15848,15 +16700,30 @@ var ts; } } } + else { + if (languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + } + } } } function checkExportDeclaration(node) { - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); + var inAmbientExternalModule = node.parent.kind === 203 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 224 && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + } + } + else { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, ts.Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } } } } @@ -15867,67 +16734,58 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 221 ? node.parent : node.parent.parent; - if (container.kind === 200 && container.name.kind === 64) { + var container = node.parent.kind === 224 ? node.parent : node.parent.parent; + if (container.kind === 202 && container.name.kind === 65) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); return; } - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 64) { - markExportAsReferenced(node); + if (node.expression) { + if (node.expression.kind === 65) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } } - else { - checkExpressionCached(node.expression); + if (node.type) { + checkSourceElement(node.type); + if (!ts.isInAmbientContext(node)) { + grammarErrorOnFirstToken(node.type, ts.Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration); + } } checkExternalModuleExports(container); + if (node.isExportEquals && languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } } function getModuleStatements(node) { - if (node.kind === 221) { + if (node.kind === 224) { return node.statements; } - if (node.kind === 200 && node.body.kind === 201) { + if (node.kind === 202 && node.body.kind === 203) { return node.body.statements; } return emptyArray; } function hasExportedMembers(moduleSymbol) { - var declarations = moduleSymbol.declarations; - for (var _i = 0, _n = declarations.length; _i < _n; _i++) { - var current = declarations[_i]; - var statements = getModuleStatements(current); - for (var _a = 0, _b = statements.length; _a < _b; _a++) { - var node = statements[_a]; - if (node.kind === 210) { - var exportClause = node.exportClause; - if (!exportClause) { - return true; - } - var specifiers = exportClause.elements; - for (var _c = 0, _d = specifiers.length; _c < _d; _c++) { - var specifier = specifiers[_c]; - if (!(specifier.propertyName && specifier.name && specifier.name.text === "default")) { - return true; - } - } - } - else if (node.kind !== 209 && node.flags & 1 && !(node.flags & 256)) { - return true; - } + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; } } + return false; } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - if (hasExportedMembers(moduleSymbol)) { - var declaration = getDeclarationOfAliasSymbol(defaultSymbol) || defaultSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } + var exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } links.exportsChecked = true; } @@ -15936,162 +16794,162 @@ var ts; if (!node) return; switch (node.kind) { - case 127: - return checkTypeParameter(node); case 128: - return checkParameter(node); - case 130: + return checkTypeParameter(node); case 129: - return checkPropertyDeclaration(node); - case 140: - case 141: - case 136: - case 137: - return checkSignatureDeclaration(node); - case 138: - return checkSignatureDeclaration(node); + return checkParameter(node); case 132: case 131: - return checkMethodDeclaration(node); - case 133: - return checkConstructorDeclaration(node); - case 134: - case 135: - return checkAccessorDeclaration(node); - case 139: - return checkTypeReference(node); + return checkPropertyDeclaration(node); case 142: - return checkTypeQuery(node); case 143: - return checkTypeLiteral(node); + case 138: + case 139: + return checkSignatureDeclaration(node); + case 140: + return checkSignatureDeclaration(node); + case 134: + case 133: + return checkMethodDeclaration(node); + case 135: + return checkConstructorDeclaration(node); + case 136: + case 137: + return checkAccessorDeclaration(node); + case 141: + return checkTypeReference(node); case 144: - return checkArrayType(node); + return checkTypeQuery(node); case 145: - return checkTupleType(node); + return checkTypeLiteral(node); case 146: - return checkUnionType(node); + return checkArrayType(node); case 147: + return checkTupleType(node); + case 148: + return checkUnionType(node); + case 149: return checkSourceElement(node.type); - case 195: - return checkFunctionDeclaration(node); - case 174: - case 201: - return checkBlock(node); - case 175: - return checkVariableStatement(node); - case 177: - return checkExpressionStatement(node); - case 178: - return checkIfStatement(node); - case 179: - return checkDoStatement(node); - case 180: - return checkWhileStatement(node); - case 181: - return checkForStatement(node); - case 182: - return checkForInStatement(node); - case 183: - return checkForOfStatement(node); - case 184: - case 185: - return checkBreakOrContinueStatement(node); - case 186: - return checkReturnStatement(node); - case 187: - return checkWithStatement(node); - case 188: - return checkSwitchStatement(node); - case 189: - return checkLabeledStatement(node); - case 190: - return checkThrowStatement(node); - case 191: - return checkTryStatement(node); - case 193: - return checkVariableDeclaration(node); - case 150: - return checkBindingElement(node); - case 196: - return checkClassDeclaration(node); case 197: - return checkInterfaceDeclaration(node); - case 198: - return checkTypeAliasDeclaration(node); - case 199: - return checkEnumDeclaration(node); - case 200: - return checkModuleDeclaration(node); - case 204: - return checkImportDeclaration(node); - case 203: - return checkImportEqualsDeclaration(node); - case 210: - return checkExportDeclaration(node); - case 209: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 176: - checkGrammarStatementInAmbientContext(node); - return; + case 203: + return checkBlock(node); + case 177: + return checkVariableStatement(node); + case 179: + return checkExpressionStatement(node); + case 180: + return checkIfStatement(node); + case 181: + return checkDoStatement(node); + case 182: + return checkWhileStatement(node); + case 183: + return checkForStatement(node); + case 184: + return checkForInStatement(node); + case 185: + return checkForOfStatement(node); + case 186: + case 187: + return checkBreakOrContinueStatement(node); + case 188: + return checkReturnStatement(node); + case 189: + return checkWithStatement(node); + case 190: + return checkSwitchStatement(node); + case 191: + return checkLabeledStatement(node); case 192: + return checkThrowStatement(node); + case 193: + return checkTryStatement(node); + case 195: + return checkVariableDeclaration(node); + case 152: + return checkBindingElement(node); + case 198: + return checkClassDeclaration(node); + case 199: + return checkInterfaceDeclaration(node); + case 200: + return checkTypeAliasDeclaration(node); + case 201: + return checkEnumDeclaration(node); + case 202: + return checkModuleDeclaration(node); + case 206: + return checkImportDeclaration(node); + case 205: + return checkImportEqualsDeclaration(node); + case 212: + return checkExportDeclaration(node); + case 211: + return checkExportAssignment(node); + case 178: checkGrammarStatementInAmbientContext(node); return; + case 194: + checkGrammarStatementInAmbientContext(node); + return; + case 215: + return checkMissingDeclaration(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 160: - case 161: + case 162: + case 163: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 132: - case 131: + case 134: + case 133: ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 133: - case 134: case 135: - case 195: + case 136: + case 137: + case 197: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 187: + case 189: checkFunctionExpressionBodies(node.expression); break; - case 128: - case 130: case 129: - case 148: - case 149: + case 132: + case 131: case 150: case 151: case 152: - case 218: case 153: case 154: + case 221: case 155: case 156: case 157: - case 169: - case 173: case 158: case 159: - case 163: - case 164: - case 162: + case 171: + case 175: + case 160: + case 161: case 165: case 166: + case 164: case 167: case 168: - case 171: - case 174: - case 201: - case 175: + case 169: + case 170: + case 173: + case 176: + case 203: case 177: - case 178: case 179: case 180: case 181: @@ -16100,21 +16958,23 @@ var ts; case 184: case 185: case 186: + case 187: case 188: - case 202: - case 214: - case 215: - case 189: case 190: - case 191: + case 204: case 217: + case 218: + case 191: + case 192: case 193: - case 194: - case 196: - case 199: case 220: - case 209: - case 221: + case 195: + case 196: + case 198: + case 201: + case 223: + case 211: + case 224: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -16142,6 +17002,9 @@ var ts; if (emitExtends) { links.flags |= 8; } + if (emitDecorate) { + links.flags |= 512; + } links.flags |= 1; } } @@ -16166,7 +17029,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 187 && node.parent.statement === node) { + if (node.parent.kind === 189 && node.parent.statement === node) { return true; } node = node.parent; @@ -16177,6 +17040,44 @@ var ts; function getSymbolsInScope(location, meaning) { var symbols = {}; var memberFlags = 0; + if (isInsideWithStatementBody(location)) { + return []; + } + populateSymbols(); + return symbolsToArray(symbols); + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + switch (location.kind) { + case 224: + if (!ts.isExternalModule(location)) { + break; + } + case 202: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); + break; + case 201: + copySymbols(getSymbolOfNode(location).exports, meaning & 8); + break; + case 198: + case 199: + if (!(memberFlags & 128)) { + copySymbols(getSymbolOfNode(location).members, meaning & 793056); + } + break; + case 162: + if (location.name) { + copySymbol(location.symbol, meaning); + } + break; + } + memberFlags = location.flags; + location = location.parent; + } + copySymbols(globals, meaning); + } function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; @@ -16202,22 +17103,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 221: + case 224: if (!ts.isExternalModule(location)) break; - case 200: + case 202: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 199: + case 201: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 196: - case 197: + case 198: + case 199: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 160: + case 162: if (location.name) { copySymbol(location.symbol, meaning); } @@ -16227,97 +17128,97 @@ var ts; location = location.parent; } copySymbols(globals, meaning); - return ts.mapToArray(symbols); + return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 64 && + return name.kind == 65 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 127: - case 196: - case 197: + case 128: case 198: case 199: + case 200: + case 201: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 125) + while (node.parent && node.parent.kind === 126) node = node.parent; - return node.parent && node.parent.kind === 139; + return node.parent && node.parent.kind === 141; } function isTypeNode(node) { - if (139 <= node.kind && node.kind <= 147) { + if (141 <= node.kind && node.kind <= 149) { return true; } switch (node.kind) { - case 111: - case 118: - case 120: case 112: + case 119: case 121: + case 113: + case 122: return true; - case 98: - return node.parent.kind !== 164; + case 99: + return node.parent.kind !== 166; case 8: - return node.parent.kind === 128; - case 64: - if (node.parent.kind === 125 && node.parent.right === node) { + return node.parent.kind === 129; + case 65: + if (node.parent.kind === 126 && node.parent.right === node) { node = node.parent; } - case 125: - ts.Debug.assert(node.kind === 64 || node.kind === 125, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); - var _parent = node.parent; - if (_parent.kind === 142) { + case 126: + ts.Debug.assert(node.kind === 65 || node.kind === 126, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + var parent_5 = node.parent; + if (parent_5.kind === 144) { return false; } - if (139 <= _parent.kind && _parent.kind <= 147) { + if (141 <= parent_5.kind && parent_5.kind <= 149) { return true; } - switch (_parent.kind) { - case 127: - return node === _parent.constraint; - case 130: - case 129: + switch (parent_5.kind) { case 128: - case 193: - return node === _parent.type; - case 195: - case 160: - case 161: - case 133: + return node === parent_5.constraint; case 132: case 131: - case 134: + case 129: + case 195: + return node === parent_5.type; + case 197: + case 162: + case 163: case 135: - return node === _parent.type; + case 134: + case 133: case 136: case 137: + return node === parent_5.type; case 138: - return node === _parent.type; - case 158: - return node === _parent.type; - case 155: - case 156: - return _parent.typeArguments && ts.indexOf(_parent.typeArguments, node) >= 0; + case 139: + case 140: + return node === parent_5.type; + case 160: + return node === parent_5.type; case 157: + case 158: + return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; + case 159: return false; } } return false; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 125) { + while (nodeOnRightSide.parent.kind === 126) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 203) { + if (nodeOnRightSide.parent.kind === 205) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209) { + if (nodeOnRightSide.parent.kind === 211) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -16326,17 +17227,17 @@ var ts; return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 125 && node.parent.right === node) || - (node.parent.kind === 153 && node.parent.name === node); + return (node.parent.kind === 126 && node.parent.right === node) || + (node.parent.kind === 155 && node.parent.name === node); } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 209) { + if (entityName.parent.kind === 211) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 153) { + if (entityName.kind !== 155) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -16348,29 +17249,29 @@ var ts; if (ts.getFullWidth(entityName) === 0) { return undefined; } - if (entityName.kind === 64) { + if (entityName.kind === 65) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 153) { + else if (entityName.kind === 155) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 125) { - var _symbol = getNodeLinks(entityName).resolvedSymbol; - if (!_symbol) { + else if (entityName.kind === 126) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { checkQualifiedName(entityName); } return getNodeLinks(entityName).resolvedSymbol; } } else if (isTypeReferenceIdentifier(entityName)) { - var _meaning = entityName.parent.kind === 139 ? 793056 : 1536; - _meaning |= 8388608; - return resolveEntityName(entityName, _meaning); + var meaning = entityName.parent.kind === 141 ? 793056 : 1536; + meaning |= 8388608; + return resolveEntityName(entityName, meaning); } return undefined; } @@ -16381,23 +17282,23 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 64 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 209 + if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 211 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { - case 64: - case 153: - case 125: + case 65: + case 155: + case 126: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 92: - case 90: + case 93: + case 91: var type = checkExpression(node); return type.symbol; - case 113: + case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 133) { + if (constructorDeclaration && constructorDeclaration.kind === 135) { return constructorDeclaration.parent.symbol; } return undefined; @@ -16405,12 +17306,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 204 || node.parent.kind === 210) && + ((node.parent.kind === 206 || node.parent.kind === 212) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 154 && node.parent.argumentExpression === node) { + if (node.parent.kind == 156 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -16424,7 +17325,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 219) { + if (location && location.kind === 222) { return resolveEntityName(location.name, 107455); } return undefined; @@ -16444,21 +17345,21 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var _symbol = getSymbolInfo(node); - return _symbol && getDeclaredTypeOfSymbol(_symbol); + var symbol = getSymbolInfo(node); + return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - var _symbol_1 = getSymbolOfNode(node); - return getTypeOfSymbol(_symbol_1); + var symbol = getSymbolOfNode(node); + return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var _symbol_2 = getSymbolInfo(node); - return _symbol_2 && getTypeOfSymbol(_symbol_2); + var symbol = getSymbolInfo(node); + return symbol && getTypeOfSymbol(symbol); } if (isInRightSideOfImportOrExportAssignment(node)) { - var _symbol_3 = getSymbolInfo(node); - var declaredType = _symbol_3 && getDeclaredTypeOfSymbol(_symbol_3); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(_symbol_3); + var symbol = getSymbolInfo(node); + var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); + return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } return unknownType; } @@ -16483,9 +17384,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols = []; - var _name = symbol.name; + var name_10 = symbol.name; ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { - symbols.push(getPropertyOfType(t, _name)); + symbols.push(getPropertyOfType(t, name_10)); }); return symbols; } @@ -16498,160 +17399,73 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 221; + return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 224; } - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; + function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { + if (languageVersion >= 2) { + return undefined; } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } + var node = getDeclarationOfAliasSymbol(symbol); + if (node) { + if (node.kind === 207) { + return getGeneratedNameForNode(node.parent) + ".default"; } - } - return true; - } - function getGeneratedNamesForSourceFile(sourceFile) { - var links = getNodeLinks(sourceFile); - var generatedNames = links.generatedNames; - if (!generatedNames) { - generatedNames = links.generatedNames = {}; - generateNames(sourceFile); - } - return generatedNames; - function generateNames(node) { - switch (node.kind) { - case 195: - case 196: - generateNameForFunctionOrClassDeclaration(node); - break; - case 200: - generateNameForModuleOrEnum(node); - generateNames(node.body); - break; - case 199: - generateNameForModuleOrEnum(node); - break; - case 204: - generateNameForImportDeclaration(node); - break; - case 210: - generateNameForExportDeclaration(node); - break; - case 209: - generateNameForExportAssignment(node); - break; - case 221: - case 201: - ts.forEach(node.statements, generateNames); - break; - } - } - function isExistingName(name) { - return ts.hasProperty(globals, name) || ts.hasProperty(sourceFile.identifiers, name) || ts.hasProperty(generatedNames, name); - } - function makeUniqueName(baseName) { - var _name = ts.generateUniqueName(baseName, isExistingName); - return generatedNames[_name] = _name; - } - function assignGeneratedName(node, name) { - getNodeLinks(node).generatedName = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } - function generateNameForModuleOrEnum(node) { - if (node.name.kind === 64) { - var _name = node.name.text; - assignGeneratedName(node, isUniqueLocalName(_name, node) ? _name : makeUniqueName(_name)); - } - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); - } - function generateNameForImportDeclaration(node) { - if (node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 207) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression.kind !== 64) { - assignGeneratedName(node, makeUniqueName("default")); + if (node.kind === 210) { + var moduleName = getGeneratedNameForNode(node.parent.parent.parent); + var propertyName = node.propertyName || node.name; + return moduleName + "." + ts.unescapeIdentifier(propertyName.text); } } } - function getGeneratedNameForNode(node) { - var links = getNodeLinks(node); - if (!links.generatedName) { - getGeneratedNamesForSourceFile(getSourceFile(node)); - } - return links.generatedName; - } - function getLocalNameOfContainer(container) { - return getGeneratedNameForNode(container); - } - function getLocalNameForImportDeclaration(node) { - return getGeneratedNameForNode(node); - } - function getAliasNameSubstitution(symbol) { - var declaration = getDeclarationOfAliasSymbol(symbol); - if (declaration && declaration.kind === 208) { - var moduleName = getGeneratedNameForNode(declaration.parent.parent.parent); - var propertyName = declaration.propertyName || declaration.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - function getExportNameSubstitution(symbol, location) { + function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { if (isExternalModuleSymbol(symbol.parent)) { + if (languageVersion >= 2) { + return undefined; + } return "exports." + ts.unescapeIdentifier(symbol.name); } var node = location; var containerSymbol = getParentOfSymbol(symbol); while (node) { - if ((node.kind === 200 || node.kind === 199) && getSymbolOfNode(node) === containerSymbol) { + if ((node.kind === 202 || node.kind === 201) && getSymbolOfNode(node) === containerSymbol) { return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); } node = node.parent; } } - function getExpressionNameSubstitution(node) { - var symbol = getNodeLinks(node).resolvedSymbol; + function getExpressionNameSubstitution(node, getGeneratedNameForNode) { + var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); if (symbol) { if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent); + return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); } var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (symbol !== exportSymbol && !(exportSymbol.flags & 944)) { - return getExportNameSubstitution(exportSymbol, node.parent); + return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); } if (symbol.flags & 8388608) { - return getAliasNameSubstitution(symbol); + return getAliasNameSubstitution(symbol, getGeneratedNameForNode); } } } - function hasExportDefaultValue(node) { - var symbol = getResolvedExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbol !== unknownSymbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol); + function isValueAliasDeclaration(node) { + switch (node.kind) { + case 205: + case 207: + case 208: + case 210: + case 214: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 212: + var exportClause = node.exportClause; + return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 211: + return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 221 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 224 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } return isAliasResolvedToValue(getSymbolOfNode(node)); @@ -16663,14 +17477,17 @@ var ts; function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; } - function isReferencedAliasDeclaration(node) { - if (isAliasSymbolDeclaration(node)) { + function isReferencedAliasDeclaration(node, checkChildren) { + if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { return true; } } - return ts.forEachChild(node, isReferencedAliasDeclaration); + if (checkChildren) { + return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + } + return false; } function isImplementationOfOverload(node) { if (ts.nodeIsPresent(node.body)) { @@ -16689,15 +17506,13 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 220) { + if (node.kind === 223) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8)) { - var declaration = symbol.valueDeclaration; - var constantValue; - if (declaration.kind === 220) { - return getEnumMemberValue(declaration); + if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); } } return undefined; @@ -16713,42 +17528,48 @@ var ts; var signature = getSignatureFromDeclaration(signatureDeclaration); getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } - function isUnknownIdentifier(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "isUnknownIdentifier called with a synthesized location"); - return !resolveName(location, name, 107455, undefined, undefined) && - !ts.hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name); + function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function hasGlobalName(name) { + return ts.hasProperty(globals, name); + } + function resolvesToSomeValue(location, name) { + ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); + return !!resolveName(location, name, 107455, undefined, undefined); } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - if (n.parent.kind === 153 && - n.parent.name === n) { - return undefined; - } - if (n.parent.kind === 150 && - n.parent.propertyName === n) { - return undefined; - } - var declarationSymbol = (n.parent.kind === 193 && n.parent.name === n) || - n.parent.kind === 150 - ? getSymbolOfNode(n.parent) - : undefined; - var symbol = declarationSymbol || + var isVariableDeclarationOrBindingElement = n.parent.kind === 152 || (n.parent.kind === 195 && n.parent.name === n); + var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 217; + symbol.valueDeclaration.parent.kind !== 220; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; } return undefined; } + function instantiateSingleCallFunctionType(functionType, typeArguments) { + if (functionType === unknownType) { + return unknownType; + } + var signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } function createResolver() { return { - getGeneratedNameForNode: getGeneratedNameForNode, getExpressionNameSubstitution: getExpressionNameSubstitution, - hasExportDefaultValue: hasExportDefaultValue, + isValueAliasDeclaration: isValueAliasDeclaration, + hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, getNodeCheckFlags: getNodeCheckFlags, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, @@ -16756,10 +17577,12 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression: writeTypeOfExpression, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - isUnknownIdentifier: isUnknownIdentifier, + resolvesToSomeValue: resolvesToSomeValue, + collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId }; } @@ -16784,6 +17607,11 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); + globalClassDecoratorType = getGlobalType("ClassDecorator"); + globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); + globalMethodDecoratorType = getGlobalType("MethodDecorator"); + globalParameterDecoratorType = getGlobalType("ParameterDecorator"); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -16797,28 +17625,46 @@ var ts; } anyArrayType = createArrayType(anyType); } + function checkGrammarDecorators(node) { + if (!node.decorators) { + return false; + } + if (!ts.nodeCanBeDecorated(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + else if (languageVersion < 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (node.kind === 136 || node.kind === 137) { + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } function checkGrammarModifiers(node) { switch (node.kind) { - case 134: + case 136: + case 137: case 135: - case 133: - case 130: - case 129: case 132: case 131: - case 138: - case 196: + case 134: + case 133: + case 140: + case 198: + case 199: + case 202: + case 201: + case 177: case 197: case 200: - case 199: - case 175: - case 195: - case 198: - case 204: - case 203: - case 210: - case 209: - case 128: + case 206: + case 205: + case 212: + case 211: + case 129: break; default: return false; @@ -16831,14 +17677,14 @@ var ts; for (var _i = 0, _a = node.modifiers, _n = _a.length; _i < _n; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 109: case 108: case 107: - case 106: var text = void 0; - if (modifier.kind === 108) { + if (modifier.kind === 109) { text = "public"; } - else if (modifier.kind === 107) { + else if (modifier.kind === 108) { text = "protected"; lastProtected = modifier; } @@ -16852,50 +17698,50 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 201 || node.parent.kind === 221) { + else if (node.parent.kind === 203 || node.parent.kind === 224) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); break; - case 109: + case 110: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 201 || node.parent.kind === 221) { + else if (node.parent.kind === 203 || node.parent.kind === 224) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; lastStatic = modifier; break; - case 77: + case 78: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 114: + case 115: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 201) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 203) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -16903,7 +17749,7 @@ var ts; break; } } - if (node.kind === 133) { + if (node.kind === 135) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -16914,13 +17760,13 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 204 || node.kind === 203) && flags & 2) { + else if ((node.kind === 206 || node.kind === 205) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 197 && flags & 2) { + else if (node.kind === 199 && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } - else if (node.kind === 128 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 129 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -16932,15 +17778,14 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters) { + function checkGrammarTypeParameterList(node, typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } if (typeParameters && typeParameters.length === 0) { var start = typeParameters.pos - "<".length; - var sourceFile = ts.getSourceFileOfNode(node); - var end = ts.skipTrivia(sourceFile.text, typeParameters.end) + ">".length; - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); + var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } } function checkGrammarParameterList(parameters) { @@ -16976,7 +17821,20 @@ var ts; } } function checkGrammarFunctionLikeDeclaration(node) { - return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); + var file = ts.getSourceFileOfNode(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + } + function checkGrammarArrowFunction(node, file) { + if (node.kind === 163) { + var arrowFunction = node; + var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + if (startLine !== endLine) { + return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); + } + } + return false; } function checkGrammarIndexSignatureParameters(node) { var parameter = node.parameters[0]; @@ -17003,7 +17861,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 120 && parameter.type.kind !== 118) { + if (parameter.type.kind !== 121 && parameter.type.kind !== 119) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -17016,7 +17874,7 @@ var ts; } } function checkGrammarIndexSignature(node) { - checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); } function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { if (typeArguments && typeArguments.length === 0) { @@ -17035,7 +17893,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, _n = arguments.length; _i < _n; _i++) { var arg = arguments[_i]; - if (arg.kind === 172) { + if (arg.kind === 174) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -17059,10 +17917,10 @@ var ts; function checkGrammarClassDeclarationHeritageClauses(node) { var seenExtendsClause = false; var seenImplementsClause = false; - if (!checkGrammarModifiers(node) && node.heritageClauses) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses, _n = _a.length; _i < _n; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 78) { + if (heritageClause.token === 79) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -17075,7 +17933,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -17090,14 +17948,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses, _n = _a.length; _i < _n; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 78) { + if (heritageClause.token === 79) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -17106,11 +17964,11 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 126) { + if (node.kind !== 127) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 167 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 169 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -17136,52 +17994,52 @@ var ts; var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties, _n = _a.length; _i < _n; _i++) { var prop = _a[_i]; - var _name = prop.name; - if (prop.kind === 172 || - _name.kind === 126) { - checkGrammarComputedPropertyName(_name); + var name_11 = prop.name; + if (prop.kind === 174 || + name_11.kind === 127) { + checkGrammarComputedPropertyName(name_11); continue; } var currentKind = void 0; - if (prop.kind === 218 || prop.kind === 219) { + if (prop.kind === 221 || prop.kind === 222) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (_name.kind === 7) { - checkGrammarNumbericLiteral(_name); + if (name_11.kind === 7) { + checkGrammarNumbericLiteral(name_11); } currentKind = Property; } - else if (prop.kind === 132) { + else if (prop.kind === 134) { currentKind = Property; } - else if (prop.kind === 134) { + else if (prop.kind === 136) { currentKind = GetAccessor; } - else if (prop.kind === 135) { + else if (prop.kind === 137) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, _name.text)) { - seen[_name.text] = currentKind; + if (!ts.hasProperty(seen, name_11.text)) { + seen[name_11.text] = currentKind; } else { - var existingKind = seen[_name.text]; + var existingKind = seen[name_11.text]; if (currentKind === Property && existingKind === Property) { if (inStrictMode) { - grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); } } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[_name.text] = currentKind | existingKind; + seen[name_11.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -17190,27 +18048,27 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 194) { + if (forInOrOfStatement.initializer.kind === 196) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var _diagnostic = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; - return grammarErrorOnNode(firstDeclaration.name, _diagnostic); + return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var _diagnostic_1 = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; - return grammarErrorOnNode(firstDeclaration, _diagnostic_1); + return grammarErrorOnNode(firstDeclaration, diagnostic); } } } @@ -17230,10 +18088,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 134 && accessor.parameters.length) { + else if (kind === 136 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 135) { + else if (kind === 137) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -17258,7 +18116,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 126 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 127 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -17268,7 +18126,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 152) { + if (node.parent.kind === 154) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -17276,7 +18134,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 196) { + if (node.parent.kind === 198) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -17287,22 +18145,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 197) { + else if (node.parent.kind === 199) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 143) { + else if (node.parent.kind === 145) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 183: + case 184: + case 185: case 181: case 182: - case 183: - case 179: - case 180: return true; - case 189: + case 191: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -17314,9 +18172,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 189: + case 191: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 184 + var isMisplacedContinueLabel = node.kind === 186 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -17324,8 +18182,8 @@ var ts; return false; } break; - case 188: - if (node.kind === 185 && !node.label) { + case 190: + if (node.kind === 187 && !node.label) { return false; } break; @@ -17338,16 +18196,16 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 185 + var message = node.kind === 187 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var _message = node.kind === 185 + var message = node.kind === 187 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, _message); + return grammarErrorOnNode(node, message); } } function checkGrammarBindingElement(node) { @@ -17363,7 +18221,7 @@ var ts; return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 182 && node.parent.parent.kind !== 183) { + if (node.parent.parent.kind !== 184 && node.parent.parent.kind !== 185) { if (ts.isInAmbientContext(node)) { if (ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); @@ -17387,7 +18245,7 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 64) { + if (name.kind === 65) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -17411,15 +18269,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 178: - case 179: case 180: - case 187: case 181: case 182: - case 183: - return false; case 189: + case 183: + case 184: + case 185: + return false; + case 191: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -17435,7 +18293,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 165) { + if (expression.kind === 167) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -17454,7 +18312,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members, _n = _a.length; _i < _n; _i++) { var node = _a[_i]; - if (node.name.kind === 126) { + if (node.name.kind === 127) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -17497,7 +18355,7 @@ var ts; } } function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 64) { + if (name && name.kind === 65) { var identifier = name; if (contextNode && (contextNode.parserContextFlags & 1) && ts.isEvalOrArgumentsIdentifier(identifier)) { var nameText = ts.declarationNameToString(identifier); @@ -17516,18 +18374,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 196) { + if (node.parent.kind === 198) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 197) { + else if (node.parent.kind === 199) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 143) { + else if (node.parent.kind === 145) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -17537,12 +18395,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 197 || - node.kind === 204 || - node.kind === 203 || - node.kind === 210 || - node.kind === 209 || - (node.flags & 2)) { + if (node.kind === 199 || + node.kind === 206 || + node.kind === 205 || + node.kind === 212 || + node.kind === 211 || + (node.flags & 2) || + (node.flags & (1 | 256))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -17550,7 +18409,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements, _n = _a.length; _i < _n; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 175) { + if (ts.isDeclaration(decl) || decl.kind === 177) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -17569,10 +18428,10 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 174 || node.parent.kind === 201 || node.parent.kind === 221) { - var _links = getNodeLinks(node.parent); - if (!_links.hasReportedStatementInAmbientContext) { - return _links.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + if (node.parent.kind === 176 || node.parent.kind === 203 || node.parent.kind === 224) { + var links_1 = getNodeLinks(node.parent); + if (!links_1.hasReportedStatementInAmbientContext) { + return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } else { @@ -17602,251 +18461,16 @@ var ts; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); +/// var ts; (function (ts) { - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!ts.isDeclarationFile(sourceFile)) { - if ((ts.isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - return true; - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(ts.getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - var lineCount = ts.getLineStarts(currentSourceFile).length; - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : ts.getStartPositionOfLine(currentLine + 1, currentSourceFile); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(ts.getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 133 && ts.nodeIsPresent(member.body)) { - return member; - } - }); - } - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var getAccessor; - var setAccessor; - if (ts.hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 134) { - getAccessor = accessor; - } - else if (accessor.kind === 135) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 134 || member.kind === 135) - && (member.flags & 128) === (accessor.flags & 128)) { - var memberName = ts.getPropertyNameForPropertyNameNode(member.name); - var accessorName = ts.getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 134 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 135 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); + function getDeclarationDiagnostics(host, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); @@ -17862,7 +18486,8 @@ var ts; var reportedDeclarationError = false; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; - var aliasDeclarationEmitInfo = []; + var moduleElementDeclarationEmitInfo = []; + var asynchronousSubModuleDeclarationEmitInfo; var referencePathsOutput = ""; if (root) { if (!compilerOptions.noResolve) { @@ -17870,25 +18495,38 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); if (referencedFile && ((referencedFile.flags & 2048) || - shouldEmitToOwnFile(referencedFile, compilerOptions) || + ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); - if (!isExternalModuleOrDeclarationFile(referencedFile)) { + if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { addedGlobalFileReference = true; } } }); } emitSourceFile(root); + if (moduleElementDeclarationEmitInfo.length) { + var oldWriter = writer; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.isVisible) { + ts.Debug.assert(aliasEmitInfo.node.kind === 206); + createAndSetNewTextWriterWithSymbolWriter(); + ts.Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } } else { var emittedReferencedFiles = []; ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { + if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { if (!compilerOptions.noResolve) { ts.forEach(sourceFile.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); - if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && + if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) { writeReferencePath(referencedFile); emittedReferencedFiles.push(referencedFile); @@ -17901,7 +18539,7 @@ var ts; } return { reportedDeclarationError: reportedDeclarationError, - aliasDeclarationEmitInfo: aliasDeclarationEmitInfo, + moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), referencePathsOutput: referencePathsOutput }; @@ -17920,17 +18558,17 @@ var ts; } } function createAndSetNewTextWriterWithSymbolWriter() { - var _writer = createTextWriter(newLine); - _writer.trackSymbol = trackSymbol; - _writer.writeKeyword = _writer.write; - _writer.writeOperator = _writer.write; - _writer.writePunctuation = _writer.write; - _writer.writeSpace = _writer.write; - _writer.writeStringLiteral = _writer.writeLiteral; - _writer.writeParameter = _writer.write; - _writer.writeSymbol = _writer.write; - setWriter(_writer); - return _writer; + var writer = ts.createTextWriter(newLine); + writer.trackSymbol = trackSymbol; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + setWriter(writer); + return writer; } function setWriter(newWriter) { writer = newWriter; @@ -17940,17 +18578,43 @@ var ts; increaseIndent = newWriter.increaseIndent; decreaseIndent = newWriter.decreaseIndent; } - function writeAsychronousImportEqualsDeclarations(importEqualsDeclarations) { + function writeAsynchronousModuleElements(nodes) { var oldWriter = writer; - ts.forEach(importEqualsDeclarations, function (aliasToWrite) { - var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); - if (aliasEmitInfo) { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); + ts.forEach(nodes, function (declaration) { + var nodeToCheck; + if (declaration.kind === 195) { + nodeToCheck = declaration.parent.parent; + } + else if (declaration.kind === 209 || declaration.kind === 210 || declaration.kind === 207) { + ts.Debug.fail("We should be getting ImportDeclaration instead to write"); + } + else { + nodeToCheck = declaration; + } + var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + } + if (moduleElementEmitInfo) { + if (moduleElementEmitInfo.node.kind === 206) { + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + if (nodeToCheck.kind === 202) { + ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === 202) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); } - writeImportEqualsDeclaration(aliasToWrite); - aliasEmitInfo.asynchronousOutput = writer.getText(); } }); setWriter(oldWriter); @@ -17958,7 +18622,7 @@ var ts; function handleSymbolAccessibilityError(symbolAccesibilityResult) { if (symbolAccesibilityResult.accessibility === 0) { if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportEqualsDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); } } else { @@ -18003,25 +18667,27 @@ var ts; emit(node); } } - function emitSeparatedList(nodes, separator, eachNodeEmitFn) { + function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var node = nodes[_i]; - if (currentWriterPos !== writer.getTextPos()) { - write(separator); + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); } } - function emitCommaList(nodes, eachNodeEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn); + function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); } function writeJsDocComments(declaration) { if (declaration) { var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -18030,44 +18696,44 @@ var ts; } function emitType(type) { switch (type.kind) { - case 111: - case 120: - case 118: case 112: case 121: - case 98: + case 119: + case 113: + case 122: + case 99: case 8: return writeTextOfNode(currentSourceFile, type); - case 139: - return emitTypeReference(type); - case 142: - return emitTypeQuery(type); - case 144: - return emitArrayType(type); - case 145: - return emitTupleType(type); - case 146: - return emitUnionType(type); - case 147: - return emitParenType(type); - case 140: case 141: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 144: + return emitTypeQuery(type); + case 146: + return emitArrayType(type); + case 147: + return emitTupleType(type); + case 148: + return emitUnionType(type); + case 149: + return emitParenType(type); + case 142: case 143: + return emitSignatureDeclarationWithJsDocComments(type); + case 145: return emitTypeLiteral(type); - case 64: + case 65: return emitEntityName(type); - case 125: + case 126: return emitEntityName(type); default: ts.Debug.fail("Unknown type annotation: " + type.kind); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 203 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 205 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { - if (entityName.kind === 64) { + if (entityName.kind === 65) { writeTextOfNode(currentSourceFile, entityName); } else { @@ -18125,16 +18791,100 @@ var ts; } function emitExportAssignment(node) { write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); + if (node.expression.kind === 65) { + writeTextOfNode(currentSourceFile, node.expression); + } + else { + write(": "); + if (node.type) { + emitType(node.type); + } + else { + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + } + } write(";"); writeLine(); + if (node.expression.kind === 65) { + var nodes = resolver.collectLinkedAliases(node.expression); + writeAsynchronousModuleElements(nodes); + } + function getDefaultExportAccessibilityDiagnostic(diagnostic) { + return { + diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + function isModuleElementVisible(node) { + return resolver.isDeclarationVisible(node); + } + function emitModuleElement(node, isModuleElementVisible) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + else if (node.kind === 205 || + (node.parent.kind === 224 && ts.isExternalModule(currentSourceFile))) { + var isVisible; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 224) { + asynchronousSubModuleDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + else { + if (node.kind === 206) { + var importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + } + } + function writeModuleElement(node) { + switch (node.kind) { + case 197: + return writeFunctionDeclaration(node); + case 177: + return writeVariableStatement(node); + case 199: + return writeInterfaceDeclaration(node); + case 198: + return writeClassDeclaration(node); + case 200: + return writeTypeAliasDeclaration(node); + case 201: + return writeEnumDeclaration(node); + case 202: + return writeModuleDeclaration(node); + case 205: + return writeImportEqualsDeclaration(node); + case 206: + return writeImportDeclaration(node); + default: + ts.Debug.fail("Unknown symbol kind"); + } } function emitModuleElementDeclarationFlags(node) { if (node.parent === currentSourceFile) { if (node.flags & 1) { write("export "); } - if (node.kind !== 197) { + if (node.flags & 256) { + write("default "); + } + else if (node.kind !== 199) { write("declare "); } } @@ -18150,18 +18900,6 @@ var ts; write("static "); } } - function emitImportEqualsDeclaration(node) { - var nodeEmitInfo = { - declaration: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - hasWritten: resolver.isDeclarationVisible(node) - }; - aliasDeclarationEmitInfo.push(nodeEmitInfo); - if (nodeEmitInfo.hasWritten) { - writeImportEqualsDeclaration(node); - } - } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); if (node.flags & 1) { @@ -18188,40 +18926,110 @@ var ts; }; } } - function emitModuleDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("module "); - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 201) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); + function isVisibleNamedBinding(namedBindings) { + if (namedBindings) { + if (namedBindings.kind === 208) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; } } - function emitTypeAliasDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); + function writeImportDeclaration(node) { + if (!node.importClause && !(node.flags & 1)) { + return; } + emitJsDocComments(node); + if (node.flags & 1) { + write("export "); + } + write("import "); + if (node.importClause) { + var currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + write(", "); + } + if (node.importClause.namedBindings.kind === 208) { + write("* as "); + writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); + } + else { + write("{ "); + emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + function emitImportOrExportSpecifier(node) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + function emitExportSpecifier(node) { + emitImportOrExportSpecifier(node); + var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + writeAsynchronousModuleElements(nodes); + } + function emitExportDeclaration(node) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + function writeModuleDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("module "); + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== 203) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeTypeAliasDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -18230,23 +19038,21 @@ var ts; }; } } - function emitEnumDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); + function writeEnumDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isConst(node)) { + write("const "); } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); } function emitEnumMemberDeclaration(node) { emitJsDocComments(node); @@ -18260,7 +19066,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 132 && (node.parent.flags & 32); + return node.parent.kind === 134 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -18270,15 +19076,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 140 || - node.parent.kind === 141 || - (node.parent.parent && node.parent.parent.kind === 143)) { - ts.Debug.assert(node.parent.kind === 132 || - node.parent.kind === 131 || - node.parent.kind === 140 || - node.parent.kind === 141 || - node.parent.kind === 136 || - node.parent.kind === 137); + if (node.parent.kind === 142 || + node.parent.kind === 143 || + (node.parent.parent && node.parent.parent.kind === 145)) { + ts.Debug.assert(node.parent.kind === 134 || + node.parent.kind === 133 || + node.parent.kind === 142 || + node.parent.kind === 143 || + node.parent.kind === 138 || + node.parent.kind === 139); emitType(node.constraint); } else { @@ -18288,31 +19094,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 196: + case 198: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 197: + case 199: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 137: + case 139: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: + case 138: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 132: - case 131: + case 134: + case 133: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 196) { + else if (node.parent.parent.kind === 198) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 195: + case 197: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -18340,7 +19146,7 @@ var ts; emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 196) { + if (node.parent.parent.kind === 198) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -18356,7 +19162,7 @@ var ts; } } } - function emitClassDeclaration(node) { + function writeClassDeclaration(node) { function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { @@ -18366,49 +19172,45 @@ var ts; }); } } - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassBaseTypeNode(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); - } - emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("class "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); } + emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(ts.getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; } - function emitInterfaceDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } + function writeInterfaceDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; } function emitPropertyDeclaration(node) { if (ts.hasDynamicName(node)) { @@ -18421,54 +19223,83 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 193 || resolver.isDeclarationVisible(node)) { - writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 130 || node.kind === 129) && ts.hasQuestionToken(node)) { - write("?"); + if (node.kind !== 195 || resolver.isDeclarationVisible(node)) { + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); } - if ((node.kind === 130 || node.kind === 129) && node.parent.kind === 143) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + else { + writeTextOfNode(currentSourceFile, node.name); + if ((node.kind === 132 || node.kind === 131) && ts.hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === 132 || node.kind === 131) && node.parent.kind === 145) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & 32)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 193) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + if (node.kind === 195) { + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 130 || node.kind === 129) { + else if (node.kind === 132 || node.kind === 131) { if (node.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 196) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + else if (node.parent.kind === 198) { + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, typeName: node.name } : undefined; } + function emitBindingPattern(bindingPattern) { + emitCommaList(bindingPattern.elements, emitBindingElement); + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + } + } + } } function emitTypeOfVariableDeclarationFromTypeLiteral(node) { if (node.type) { @@ -18476,30 +19307,30 @@ var ts; emitType(node.type); } } - function emitVariableStatement(node) { - var hasDeclarationWithEmit = ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - if (hasDeclarationWithEmit) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node.declarationList)) { - write("let "); - } - else if (ts.isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration); - write(";"); - writeLine(); + function isVariableStatementVisible(node) { + return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + } + function writeVariableStatement(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isLet(node.declarationList)) { + write("let "); } + else if (ts.isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); } function emitAccessorDeclaration(node) { if (ts.hasDynamicName(node)) { return; } - var accessors = getAllAccessorDeclarations(node.parent.members, node); + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); var accessorWithTypeAnnotation; if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); @@ -18510,7 +19341,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 134 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 136 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -18523,7 +19354,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 134 + return accessor.kind === 136 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -18532,7 +19363,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 135) { + if (accessorWithTypeAnnotation.kind === 137) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -18572,24 +19403,23 @@ var ts; } } } - function emitFunctionDeclaration(node) { + function writeFunctionDeclaration(node) { if (ts.hasDynamicName(node)) { return; } - if ((node.kind !== 195 || resolver.isDeclarationVisible(node)) && - !resolver.isImplementationOfOverload(node)) { + if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 195) { + if (node.kind === 197) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 132) { + else if (node.kind === 134) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 195) { + if (node.kind === 197) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 133) { + else if (node.kind === 135) { write("constructor"); } else { @@ -18606,11 +19436,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 137 || node.kind === 141) { + if (node.kind === 139 || node.kind === 143) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 138) { + if (node.kind === 140) { write("["); } else { @@ -18619,20 +19449,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 138) { + if (node.kind === 140) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 140 || node.kind === 141; - if (isFunctionTypeOrConstructorType || node.parent.kind === 143) { + var isFunctionTypeOrConstructorType = node.kind === 142 || node.kind === 143; + if (isFunctionTypeOrConstructorType || node.parent.kind === 145) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 133 && !(node.flags & 32)) { + else if (node.kind !== 135 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -18643,23 +19473,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 137: + case 139: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 136: + case 138: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 138: + case 140: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 132: - case 131: + case 134: + case 133: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -18667,7 +19497,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -18680,7 +19510,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 195: + case 197: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -18712,9 +19542,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 140 || - node.parent.kind === 141 || - node.parent.parent.kind === 143) { + if (node.parent.kind === 142 || + node.parent.kind === 143 || + node.parent.parent.kind === 145) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -18723,25 +19553,25 @@ var ts; function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 133: + case 135: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; - case 137: + case 139: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: + case 138: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 132: - case 131: + case 134: + case 133: if (node.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -18749,7 +19579,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 196) { + else if (node.parent.parent.kind === 198) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -18762,7 +19592,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 195: + case 197: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -18781,60 +19611,83 @@ var ts; } function emitNode(node) { switch (node.kind) { + case 197: + case 202: + case 205: + case 199: + case 198: + case 200: + case 201: + return emitModuleElement(node, isModuleElementVisible(node)); + case 177: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 206: + return emitModuleElement(node, !node.importClause); + case 212: + return emitExportDeclaration(node); + case 135: + case 134: case 133: - case 195: + return writeFunctionDeclaration(node); + case 139: + case 138: + case 140: + return emitSignatureDeclarationWithJsDocComments(node); + case 136: + case 137: + return emitAccessorDeclaration(node); case 132: case 131: - return emitFunctionDeclaration(node); - case 137: - case 136: - case 138: - return emitSignatureDeclarationWithJsDocComments(node); - case 134: - case 135: - return emitAccessorDeclaration(node); - case 175: - return emitVariableStatement(node); - case 130: - case 129: return emitPropertyDeclaration(node); - case 197: - return emitInterfaceDeclaration(node); - case 196: - return emitClassDeclaration(node); - case 198: - return emitTypeAliasDeclaration(node); - case 220: + case 223: return emitEnumMemberDeclaration(node); - case 199: - return emitEnumDeclaration(node); - case 200: - return emitModuleDeclaration(node); - case 203: - return emitImportEqualsDeclaration(node); - case 209: + case 211: return emitExportAssignment(node); - case 221: + case 224: return emitSourceFile(node); } } function writeReferencePath(referencedFile) { var declFileName = referencedFile.flags & 2048 ? referencedFile.fileName - : shouldEmitToOwnFile(referencedFile, compilerOptions) - ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") + : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) + ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } } - function getDeclarationDiagnostics(host, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; + function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { + var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + if (!emitDeclarationResult.reportedDeclarationError) { + var declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { + var appliedSyncOutputPos = 0; + var declarationOutput = ""; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return declarationOutput; + } } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + ts.writeDeclarationFile = writeDeclarationFile; +})(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; @@ -18843,8 +19696,8 @@ var ts; var newLine = host.getNewLine(); if (targetSourceFile === undefined) { ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, ".js"); + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -18853,8 +19706,8 @@ var ts; } } else { - if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -18867,8 +19720,26 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } function emitJavaScript(jsFilePath, root) { - var writer = createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var write = writer.write; var writeTextOfNode = writer.writeTextOfNode; var writeLine = writer.writeLine; @@ -18876,26 +19747,23 @@ var ts; var decreaseIndent = writer.decreaseIndent; var preserveNewLines = compilerOptions.preserveNewLines || false; var currentSourceFile; - var lastFrame; - var currentScopeNames; - var generatedBlockScopeNames; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var blockScopedVariableToGeneratedName; + var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; - var tempCount = 0; + var decorateEmitted = false; + var tempFlags = 0; var tempVariables; var tempParameters; var externalImports; var exportSpecifiers; - var exportDefault; + var exportEquals; + var hasExportStars; var writeEmittedFiles = writeJavaScriptFile; - var emitLeadingComments = compilerOptions.removeComments ? function (node) { } : emitLeadingDeclarationComments; - var emitTrailingComments = compilerOptions.removeComments ? function (node) { } : emitTrailingDeclarationComments; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfLocalPosition; var detachedCommentsInfo; - var emitDetachedComments = compilerOptions.removeComments ? function (node) { } : emitDetachedCommentsAtPosition; - var writeComment = writeCommentRange; - var emitNodeWithoutSourceMap = compilerOptions.removeComments ? emitNodeWithoutSourceMapWithoutComments : emitNodeWithoutSourceMapWithComments; + var writeComment = ts.writeCommentRange; var emit = emitNodeWithoutSourceMap; - var emitWithoutComments = emitNodeWithoutSourceMapWithoutComments; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; @@ -18922,55 +19790,108 @@ var ts; currentSourceFile = sourceFile; emit(sourceFile); } - function enterNameScope() { - var names = currentScopeNames; - currentScopeNames = undefined; - if (names) { - lastFrame = { names: names, previous: lastFrame }; - return true; - } - return false; + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); } - function exitNameScope(popFrame) { - if (popFrame) { - currentScopeNames = lastFrame.names; - lastFrame = lastFrame.previous; - } - else { - currentScopeNames = undefined; - } - } - function generateUniqueNameForLocation(location, baseName) { - var _name; - if (!isExistingName(location, baseName)) { - _name = baseName; - } - else { - _name = ts.generateUniqueName(baseName, function (n) { return isExistingName(location, n); }); - } - return recordNameInCurrentScope(_name); - } - function recordNameInCurrentScope(name) { - if (!currentScopeNames) { - currentScopeNames = {}; - } - return currentScopeNames[name] = name; - } - function isExistingName(location, name) { - if (!resolver.isUnknownIdentifier(location, name)) { - return true; - } - if (currentScopeNames && ts.hasProperty(currentScopeNames, name)) { - return true; - } - var frame = lastFrame; - while (frame) { - if (ts.hasProperty(frame.names, name)) { - return true; + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { + tempFlags |= flags; + return name; } - frame = frame.previous; } - return false; + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_12 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_12)) { + return name_12; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function assignGeneratedName(node, name) { + nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); + } + function generateNameForFunctionOrClassDeclaration(node) { + if (!node.name) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForModuleOrEnum(node) { + if (node.name.kind === 65) { + var name_13 = node.name.text; + assignGeneratedName(node, isUniqueLocalName(name_13, node) ? name_13 : makeUniqueName(name_13)); + } + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 8 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + assignGeneratedName(node, makeUniqueName(baseName)); + } + function generateNameForImportDeclaration(node) { + if (node.importClause) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportDeclaration(node) { + if (node.moduleSpecifier) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportAssignment(node) { + if (node.expression && node.expression.kind !== 65) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForNode(node) { + switch (node.kind) { + case 197: + case 198: + generateNameForFunctionOrClassDeclaration(node); + break; + case 202: + generateNameForModuleOrEnum(node); + generateNameForNode(node.body); + break; + case 201: + generateNameForModuleOrEnum(node); + break; + case 206: + generateNameForImportDeclaration(node); + break; + case 212: + generateNameForExportDeclaration(node); + break; + case 211: + generateNameForExportAssignment(node); + break; + } + } + function getGeneratedNameForNode(node) { + var nodeId = ts.getNodeId(node); + if (!nodeToGeneratedName[nodeId]) { + generateNameForNode(node); + } + return nodeToGeneratedName[nodeId]; } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -19096,8 +20017,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var _name = node.name; - if (!_name || _name.kind !== 126) { + var name_14 = node.name; + if (!name_14 || name_14.kind !== 127) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -19114,19 +20035,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 195 || - node.kind === 160 || - node.kind === 132 || - node.kind === 131 || + else if (node.kind === 197 || + node.kind === 162 || node.kind === 134 || - node.kind === 135 || - node.kind === 200 || - node.kind === 196 || - node.kind === 199) { + node.kind === 133 || + node.kind === 136 || + node.kind === 137 || + node.kind === 202 || + node.kind === 198 || + node.kind === 201) { if (node.name) { - var _name = node.name; - scopeName = _name.kind === 126 - ? ts.getTextOfNode(_name) + var name_15 = node.name; + scopeName = name_15.kind === 127 + ? ts.getTextOfNode(name_15) : node.name.text; } recordScopeNameStart(scopeName); @@ -19141,7 +20062,7 @@ var ts; ; function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { recordSourceMapSpan(comment.pos); - writeCommentRange(currentSourceFile, writer, comment, newLine); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { @@ -19169,7 +20090,7 @@ var ts; } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { encodeLastRecordedSourceMapSpan(); - writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); sourceMapDataList.push(sourceMapData); writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); } @@ -19192,7 +20113,7 @@ var ts; if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); if (root) { - sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, host, sourceMapDir)); + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -19205,32 +20126,24 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node) { + function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); + return emitNodeWithoutSourceMap(node, false); } - if (node.kind != 221) { + if (node.kind != 224) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, false); } } } - function emitNodeWithSourceMapWithoutComments(node) { - if (node) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMapWithoutComments(node); - recordEmitNodeEndSpan(node); - } - } writeEmittedFiles = writeJavaScriptAndSourceMapFile; emit = emitNodeWithSourceMap; - emitWithoutComments = emitNodeWithSourceMapWithoutComments; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -19239,24 +20152,11 @@ var ts; writeComment = writeCommentRangeWithMap; } function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } - function createTempVariable(location, preferredName) { - for (var name = preferredName; !name || isExistingName(location, name); tempCount++) { - var char = 97 + tempCount; - if (char === 105 || char === 110) { - continue; - } - if (tempCount < 26) { - name = "_" + String.fromCharCode(char); - } - else { - name = "_" + (tempCount - 26); - } - } - recordNameInCurrentScope(name); - var result = ts.createSynthesizedNode(64); - result.text = name; + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(65); + result.text = makeTempVariableName(flags); return result; } function recordTempDeclaration(name) { @@ -19265,8 +20165,8 @@ var ts; } tempVariables.push(name); } - function createAndRecordTempVariable(location, preferredName) { - var temp = createTempVariable(location, preferredName); + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); recordTempDeclaration(temp); return temp; } @@ -19458,7 +20358,7 @@ var ts; write("]"); } function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(node); + var tempVariable = createAndRecordTempVariable(0); write("("); emit(tempVariable); write(" = "); @@ -19471,10 +20371,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 169) { + if (node.template.kind === 171) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 167 + var needsParens = templateSpan.expression.kind === 169 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -19498,7 +20398,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 159 + var needsParens = templateSpan.expression.kind !== 161 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -19513,16 +20413,29 @@ var ts; write(")"); } function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar ts.Debug.assert(node.templateSpans.length !== 0); return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 155: - case 156: - return parent.expression === template; case 157: + case 158: + return parent.expression === template; case 159: + case 161: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -19530,7 +20443,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 167: + case 169: switch (expression.operatorToken.kind) { case 35: case 36: @@ -19542,7 +20455,7 @@ var ts; default: return -1; } - case 168: + case 170: return -1; default: return 1; @@ -19554,11 +20467,27 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 150); + ts.Debug.assert(node.kind !== 152); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 126) { + else if (node.kind === 127) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[node.id]; + if (generatedName) { + write(generatedName); + return; + } + var generatedVariable = createTempVariable(0); + generatedName = generatedVariable.text; + recordTempDeclaration(generatedVariable); + computedPropertyNamesToGeneratedNames[node.id] = generatedName; + write(generatedName); + write(" = "); + } emit(node.expression); } else { @@ -19573,38 +20502,43 @@ var ts; } } function isNotExpressionIdentifier(node) { - var _parent = node.parent; - switch (_parent.kind) { - case 128: - case 193: - case 150: - case 130: + var parent = node.parent; + switch (parent.kind) { case 129: - case 218: - case 219: - case 220: + case 195: + case 152: case 132: case 131: - case 195: + case 221: + case 222: + case 223: case 134: - case 135: - case 160: - case 196: + case 133: case 197: + case 136: + case 137: + case 162: + case 198: case 199: - case 200: - case 203: - return _parent.name === node; - case 185: - case 184: - case 209: + case 201: + case 202: + case 205: + case 207: + case 208: + return parent.name === node; + case 210: + case 214: + return parent.name === node || parent.propertyName === node; + case 187: + case 186: + case 211: return false; - case 189: + case 191: return node.parent.label === node; } } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node); + var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); if (substitution) { write(substitution); } @@ -19612,15 +20546,21 @@ var ts; writeTextOfNode(currentSourceFile, node); } } - function getBlockScopedVariableId(node) { - return !ts.nodeIsSynthesized(node) && resolver.getBlockScopedVariableId(node); + function getGeneratedNameForIdentifier(node) { + if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { + return undefined; + } + var variableId = resolver.getBlockScopedVariableId(node); + if (variableId === undefined) { + return undefined; + } + return blockScopedVariableToGeneratedName[variableId]; } - function emitIdentifier(node) { - var variableId = getBlockScopedVariableId(node); - if (variableId !== undefined && generatedBlockScopeNames) { - var text = generatedBlockScopeNames[variableId]; - if (text) { - write(text); + function emitIdentifier(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers) { + var generatedName = getGeneratedNameForIdentifier(node); + if (generatedName) { + write(generatedName); return; } } @@ -19643,15 +20583,17 @@ var ts; } } function emitSuper(node) { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 16) { - write("_super.prototype"); - } - else if (flags & 32) { - write("_super"); + if (languageVersion >= 2) { + write("super"); } else { - write("super"); + var flags = resolver.getNodeCheckFlags(node); + if (flags & 16) { + write("_super.prototype"); + } + else { + write("_super"); + } } } function emitObjectBindingPattern(node) { @@ -19668,7 +20610,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName); + emit(node.propertyName, false); write(": "); } if (node.dotDotDotToken) { @@ -19688,12 +20630,12 @@ var ts; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 64: - case 151: + case 65: case 153: - case 154: case 155: - case 159: + case 156: + case 157: + case 161: return false; } return true; @@ -19701,8 +20643,8 @@ var ts; function emitListWithSpread(elements, multiLine, trailingComma) { var pos = 0; var group = 0; - var _length = elements.length; - while (pos < _length) { + var length = elements.length; + while (pos < length) { if (group === 1) { write(".concat("); } @@ -19710,21 +20652,21 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 171) { + if (e.kind === 173) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { var i = pos; - while (i < _length && elements[i].kind !== 171) { + while (i < length && elements[i].kind !== 173) { i++; } write("["); if (multiLine) { increaseIndent(); } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === _length); + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); if (multiLine) { decreaseIndent(); } @@ -19738,7 +20680,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 171; + return node.kind === 173; } function emitArrayLiteral(node) { var elements = node.elements; @@ -19759,11 +20701,11 @@ var ts; return emit(parenthesizedObjectLiteral); } function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral, firstComputedPropertyIndex) { - var tempVar = createAndRecordTempVariable(originalObjectLiteral); - var initialObjectLiteral = ts.createSynthesizedNode(152); + var tempVar = createAndRecordTempVariable(0); + var initialObjectLiteral = ts.createSynthesizedNode(154); initialObjectLiteral.properties = originalObjectLiteral.properties.slice(0, firstComputedPropertyIndex); initialObjectLiteral.flags |= 512; - var propertyPatches = createBinaryExpression(tempVar, 52, initialObjectLiteral); + var propertyPatches = createBinaryExpression(tempVar, 53, initialObjectLiteral); ts.forEach(originalObjectLiteral.properties, function (property) { var patchedProperty = tryCreatePatchingPropertyAssignment(originalObjectLiteral, tempVar, property); if (patchedProperty) { @@ -19781,33 +20723,33 @@ var ts; function tryCreatePatchingPropertyAssignment(objectLiteral, tempVar, property) { var leftHandSide = createMemberAccessForPropertyName(tempVar, property.name); var maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property); - return maybeRightHandSide && createBinaryExpression(leftHandSide, 52, maybeRightHandSide, true); + return maybeRightHandSide && createBinaryExpression(leftHandSide, 53, maybeRightHandSide, true); } function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property) { switch (property.kind) { - case 218: + case 221: return property.initializer; - case 219: - return createIdentifier(resolver.getExpressionNameSubstitution(property.name)); - case 132: - return createFunctionExpression(property.parameters, property.body); + case 222: + return createIdentifier(resolver.getExpressionNameSubstitution(property.name, getGeneratedNameForNode)); case 134: - case 135: - var _a = getAllAccessorDeclarations(objectLiteral.properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + return createFunctionExpression(property.parameters, property.body); + case 136: + case 137: + var _a = ts.getAllAccessorDeclarations(objectLiteral.properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (firstAccessor !== property) { return undefined; } - var propertyDescriptor = ts.createSynthesizedNode(152); + var propertyDescriptor = ts.createSynthesizedNode(154); var descriptorProperties = []; if (getAccessor) { - var _getProperty = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body)); - descriptorProperties.push(_getProperty); + var getProperty_1 = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body)); + descriptorProperties.push(getProperty_1); } if (setAccessor) { var setProperty = createPropertyAssignment(createIdentifier("set"), createFunctionExpression(setAccessor.parameters, setAccessor.body)); descriptorProperties.push(setProperty); } - var trueExpr = ts.createSynthesizedNode(94); + var trueExpr = ts.createSynthesizedNode(95); var enumerableTrue = createPropertyAssignment(createIdentifier("enumerable"), trueExpr); descriptorProperties.push(enumerableTrue); var configurableTrue = createPropertyAssignment(createIdentifier("configurable"), trueExpr); @@ -19820,14 +20762,14 @@ var ts; } } function createParenthesizedExpression(expression) { - var result = ts.createSynthesizedNode(159); + var result = ts.createSynthesizedNode(161); result.expression = expression; return result; } function createNodeArray() { var elements = []; - for (var _i = 0; _i < arguments.length; _i++) { - elements[_i - 0] = arguments[_i]; + for (var _a = 0; _a < arguments.length; _a++) { + elements[_a - 0] = arguments[_a]; } var result = elements; result.pos = -1; @@ -19835,25 +20777,25 @@ var ts; return result; } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(167, startsOnNewLine); + var result = ts.createSynthesizedNode(169, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createExpressionStatement(expression) { - var result = ts.createSynthesizedNode(177); + var result = ts.createSynthesizedNode(179); result.expression = expression; return result; } function createMemberAccessForPropertyName(expression, memberName) { - if (memberName.kind === 64) { + if (memberName.kind === 65) { return createPropertyAccessExpression(expression, memberName); } else if (memberName.kind === 8 || memberName.kind === 7) { return createElementAccessExpression(expression, memberName); } - else if (memberName.kind === 126) { + else if (memberName.kind === 127) { return createElementAccessExpression(expression, memberName.expression); } else { @@ -19861,37 +20803,37 @@ var ts; } } function createPropertyAssignment(name, initializer) { - var result = ts.createSynthesizedNode(218); + var result = ts.createSynthesizedNode(221); result.name = name; result.initializer = initializer; return result; } function createFunctionExpression(parameters, body) { - var result = ts.createSynthesizedNode(160); + var result = ts.createSynthesizedNode(162); result.parameters = parameters; result.body = body; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(153); + var result = ts.createSynthesizedNode(155); result.expression = expression; result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(154); + var result = ts.createSynthesizedNode(156); result.expression = expression; result.argumentExpression = argumentExpression; return result; } function createIdentifier(name, startsOnNewLine) { - var result = ts.createSynthesizedNode(64, startsOnNewLine); + var result = ts.createSynthesizedNode(65, startsOnNewLine); result.text = name; return result; } function createCallExpression(invokedExpression, arguments) { - var result = ts.createSynthesizedNode(155); + var result = ts.createSynthesizedNode(157); result.expression = invokedExpression; result.arguments = arguments; return result; @@ -19902,7 +20844,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 126) { + if (properties[i].name.kind === 127) { numInitialNonComputedProperties = i; break; } @@ -19921,24 +20863,34 @@ var ts; } function emitComputedPropertyName(node) { write("["); - emit(node.expression); + emitExpressionForPropertyName(node); write("]"); } function emitMethod(node) { - emit(node.name); + emit(node.name, false); if (languageVersion < 2) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name); + emit(node.name, false); write(": "); emit(node.initializer); } function emitShorthandPropertyAssignment(node) { - emit(node.name); - if (languageVersion < 2 || resolver.getExpressionNameSubstitution(node.name)) { + emit(node.name, false); + if (languageVersion < 2) { + write(": "); + var generatedName = getGeneratedNameForIdentifier(node.name); + if (generatedName) { + write(generatedName); + } + else { + emitExpressionIdentifier(node.name); + } + } + else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { write(": "); emitExpressionIdentifier(node.name); } @@ -19948,7 +20900,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 153 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 155 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -19978,7 +20930,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); + emit(node.name, false); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -19996,20 +20948,20 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 171; }); + return ts.forEach(elements, function (e) { return e.kind === 173; }); } function skipParentheses(node) { - while (node.kind === 159 || node.kind === 158) { + while (node.kind === 161 || node.kind === 160) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 64 || node.kind === 92 || node.kind === 90) { + if (node.kind === 65 || node.kind === 93 || node.kind === 91) { emit(node); return node; } - var temp = createAndRecordTempVariable(node); + var temp = createAndRecordTempVariable(0); write("("); emit(temp); write(" = "); @@ -20020,18 +20972,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 153) { + if (expr.kind === 155) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 154) { + else if (expr.kind === 156) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 90) { + else if (expr.kind === 91) { target = expr; write("_super"); } @@ -20040,7 +20992,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 90) { + if (target.kind === 91) { emitThis(target); } else { @@ -20060,15 +21012,15 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 90) { - write("_super"); + if (node.expression.kind === 91) { + emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 153 && node.expression.expression.kind === 90; + superCall = node.expression.kind === 155 && node.expression.expression.kind === 91; } - if (superCall) { + if (superCall && languageVersion < 2) { write(".call("); emitThis(node.expression); if (node.arguments.length) { @@ -20093,7 +21045,7 @@ var ts; } } function emitTaggedTemplateExpression(node) { - if (compilerOptions.target >= 2) { + if (languageVersion >= 2) { emit(node.tag); write(" "); emit(node.template); @@ -20103,20 +21055,20 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 161) { - if (node.expression.kind === 158) { + if (!node.parent || node.parent.kind !== 163) { + if (node.expression.kind === 160) { var operand = node.expression.expression; - while (operand.kind == 158) { + while (operand.kind == 160) { operand = operand.expression; } - if (operand.kind !== 165 && - operand.kind !== 164 && - operand.kind !== 163 && - operand.kind !== 162 && + if (operand.kind !== 167 && operand.kind !== 166 && - operand.kind !== 156 && - !(operand.kind === 155 && node.parent.kind === 156) && - !(operand.kind === 160 && node.parent.kind === 155)) { + operand.kind !== 165 && + operand.kind !== 164 && + operand.kind !== 168 && + operand.kind !== 158 && + !(operand.kind === 157 && node.parent.kind === 158) && + !(operand.kind === 162 && node.parent.kind === 157)) { emit(operand); return; } @@ -20127,23 +21079,23 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(73)); + write(ts.tokenToString(74)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(96)); + write(ts.tokenToString(97)); write(" "); emit(node.expression); } function emitPrefixUnaryExpression(node) { write(ts.tokenToString(node.operator)); - if (node.operand.kind === 165) { + if (node.operand.kind === 167) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -20159,9 +21111,9 @@ var ts; write(ts.tokenToString(node.operator)); } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 52 && - (node.left.kind === 152 || node.left.kind === 151)) { - emitDestructuring(node, node.parent.kind === 177); + if (languageVersion < 2 && node.operatorToken.kind === 53 && + (node.left.kind === 154 || node.left.kind === 153)) { + emitDestructuring(node, node.parent.kind === 179); } else { emit(node.left); @@ -20197,7 +21149,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 174) { + if (node && node.kind === 176) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -20212,12 +21164,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 201) { - ts.Debug.assert(node.parent.kind === 200); + if (node.kind === 203) { + ts.Debug.assert(node.parent.kind === 202); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 201) { + if (node.kind === 203) { emitTempDeclarations(true); } decreaseIndent(); @@ -20226,7 +21178,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 174) { + if (node.kind === 176) { write(" "); emit(node); } @@ -20238,11 +21190,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 161); + emitParenthesizedIf(node.expression, node.expression.kind === 163); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); endPos = emitToken(16, endPos); emit(node.expression); @@ -20250,8 +21202,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(75, node.thenStatement.end); - if (node.elseStatement.kind === 178) { + emitToken(76, node.thenStatement.end); + if (node.elseStatement.kind === 180) { write(" "); emit(node.elseStatement); } @@ -20263,7 +21215,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 174) { + if (node.statement.kind === 176) { write(" "); } else { @@ -20280,13 +21232,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitStartOfVariableDeclarationList(decl, startPos) { - var tokenKind = 97; + var tokenKind = 98; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 104; + tokenKind = 105; } else if (ts.isConst(decl)) { - tokenKind = 69; + tokenKind = 70; } } if (startPos !== undefined) { @@ -20294,20 +21246,20 @@ var ts; } else { switch (tokenKind) { - case 97: + case 98: return write("var "); - case 104: + case 105: return write("let "); - case 69: + case 70: return write("const "); } } } function emitForStatement(node) { - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 194) { + if (node.initializer && node.initializer.kind === 196) { var variableDeclarationList = node.initializer; var declarations = variableDeclarationList.declarations; emitStartOfVariableDeclarationList(declarations[0], endPos); @@ -20325,13 +21277,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 183) { + if (languageVersion < 2 && node.kind === 185) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { var decl = variableDeclarationList.declarations[0]; @@ -20343,7 +21295,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 182) { + if (node.kind === 184) { write(" in "); } else { @@ -20354,13 +21306,33 @@ var ts; emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { - var endPos = emitToken(81, node.pos); + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (let _i = 0, _a = expr; _i < _a.length; _i++) { + // let v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 64; - var counter = createTempVariable(node, "_i"); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node); - var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, "_n") : undefined; + var rhsIsIdentifier = node.expression.kind === 65; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(536870912) : undefined; emitStart(node.expression); write("var "); emitNodeWithoutSourceMap(counter); @@ -20404,7 +21376,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -20419,14 +21391,14 @@ var ts; } } else { - emitNodeWithoutSourceMap(createTempVariable(node)); + emitNodeWithoutSourceMap(createTempVariable(0)); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 52, rhsIterationValue, false); - if (node.initializer.kind === 151 || node.initializer.kind === 152) { + var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); + if (node.initializer.kind === 153 || node.initializer.kind === 154) { emitDestructuring(assignmentExpression, true, undefined, node); } else { @@ -20435,7 +21407,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 174) { + if (node.statement.kind === 176) { emitLines(node.statement.statements); } else { @@ -20447,12 +21419,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 185 ? 65 : 70, node.pos); + emitToken(node.kind === 187 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(89, node.pos); + emitToken(90, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -20463,7 +21435,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(91, node.pos); + var endPos = emitToken(92, node.pos); write(" "); emitToken(16, endPos); emit(node.expression); @@ -20480,19 +21452,19 @@ var ts; emitToken(15, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function nodeEndPositionsAreOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, node2.end); + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); } function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 214) { + if (node.kind === 217) { write("case "); emit(node.expression); write(":"); @@ -20527,7 +21499,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(67, node.pos); + var endPos = emitToken(68, node.pos); write(" "); emitToken(16, endPos); emit(node.variableDeclaration); @@ -20536,7 +21508,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(71, node.pos); + emitToken(72, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -20547,18 +21519,24 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 200); + } while (node && node.kind !== 202); return node; } function emitContainingModuleName(node) { var container = getContainingModule(node); - write(container ? resolver.getGeneratedNameForNode(container) : "exports"); + write(container ? getGeneratedNameForNode(container) : "exports"); } function emitModuleMemberName(node) { emitStart(node.name); if (ts.getCombinedNodeFlags(node) & 1) { - emitContainingModuleName(node); - write("."); + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (languageVersion < 2) { + write("exports."); + } } emitNodeWithoutSourceMap(node.name); emitEnd(node.name); @@ -20566,13 +21544,30 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(166); result.expression = zero; return result; } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (node.name) { + emitModuleMemberName(node); + } + else { + write("exports.default"); + } + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + } function emitExportMemberAssignments(name) { - if (!exportDefault && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - ts.forEach(exportSpecifiers[name.text], function (specifier) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text], _c = _b.length; _a < _c; _a++) { + var specifier = _b[_a]; writeLine(); emitStart(specifier.name); emitContainingModuleName(specifier); @@ -20580,15 +21575,15 @@ var ts; emitNodeWithoutSourceMap(specifier.name); emitEnd(specifier.name); write(" = "); - emitNodeWithoutSourceMap(name); + emitExpressionIdentifier(name); write(";"); - }); + } } } function emitDestructuring(root, isAssignmentExpressionStatement, value, lowestNonSynthesizedAncestor) { var emitCount = 0; - var _isDeclaration = (root.kind === 193 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 128; - if (root.kind === 167) { + var isDeclaration = (root.kind === 195 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 129; + if (root.kind === 169) { emitAssignmentExpression(root); } else { @@ -20600,7 +21595,7 @@ var ts; write(", "); } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === 193 || name.parent.kind === 150)) { + if (name.parent && (name.parent.kind === 195 || name.parent.kind === 152)) { emitModuleMemberName(name.parent); } else { @@ -20610,9 +21605,9 @@ var ts; emit(value); } function ensureIdentifier(expr) { - if (expr.kind !== 64) { - var identifier = createTempVariable(lowestNonSynthesizedAncestor || root); - if (!_isDeclaration) { + if (expr.kind !== 65) { + var identifier = createTempVariable(0); + if (!isDeclaration) { recordTempDeclaration(identifier); } emitAssignment(identifier, expr); @@ -20622,14 +21617,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(167); + var equals = ts.createSynthesizedNode(169); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(168); + var cond = ts.createSynthesizedNode(170); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -20643,21 +21638,21 @@ var ts; return node; } function parenthesizeForAccess(expr) { - if (expr.kind === 64 || expr.kind === 153 || expr.kind === 154) { + if (expr.kind === 65 || expr.kind === 155 || expr.kind === 156) { return expr; } - var node = ts.createSynthesizedNode(159); + var node = ts.createSynthesizedNode(161); node.expression = expr; return node; } function createPropertyAccess(object, propName) { - if (propName.kind !== 64) { + if (propName.kind !== 65) { return createElementAccess(object, propName); } return createPropertyAccessExpression(parenthesizeForAccess(object), propName); } function createElementAccess(object, index) { - var node = ts.createSynthesizedNode(154); + var node = ts.createSynthesizedNode(156); node.expression = parenthesizeForAccess(object); node.argumentExpression = index; return node; @@ -20667,9 +21662,9 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value); } - for (var _i = 0, _n = properties.length; _i < _n; _i++) { - var p = properties[_i]; - if (p.kind === 218 || p.kind === 219) { + for (var _a = 0, _b = properties.length; _a < _b; _a++) { + var p = properties[_a]; + if (p.kind === 221 || p.kind === 222) { var propName = (p.name); emitDestructuringAssignment(p.initializer || propName, createPropertyAccess(value, propName)); } @@ -20682,8 +21677,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 172) { - if (e.kind !== 171) { + if (e.kind !== 174) { + if (e.kind !== 173) { emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i))); } else { @@ -20697,14 +21692,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 167 && target.operatorToken.kind === 52) { + if (target.kind === 169 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 152) { + if (target.kind === 154) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 151) { + else if (target.kind === 153) { emitArrayLiteralAssignment(target, value); } else { @@ -20713,19 +21708,19 @@ var ts; } function emitAssignmentExpression(root) { var target = root.left; - var _value = root.right; + var value = root.right; if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, _value); + emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 159) { + if (root.parent.kind !== 161) { write("("); } - _value = ensureIdentifier(_value); - emitDestructuringAssignment(target, _value); + value = ensureIdentifier(value); + emitDestructuringAssignment(target, value); write(", "); - emit(_value); - if (root.parent.kind !== 159) { + emit(value); + if (root.parent.kind !== 161) { write(")"); } } @@ -20745,11 +21740,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 148) { + if (pattern.kind === 150) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccess(value, propName)); } - else if (element.kind !== 172) { + else if (element.kind !== 174) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccess(value, createNumericLiteral(i))); } @@ -20786,8 +21781,8 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 182 && - node.parent.parent.kind !== 183) { + node.parent.parent.kind !== 184 && + node.parent.parent.kind !== 185) { initializer = createVoidZero(); } } @@ -20795,16 +21790,19 @@ var ts; } } function emitExportVariableAssignments(node) { - var _name = node.name; - if (_name.kind === 64) { - emitExportMemberAssignments(_name); + if (node.kind === 174) { + return; } - else if (ts.isBindingPattern(_name)) { - ts.forEach(_name.elements, emitExportVariableAssignments); + var name = node.name; + if (name.kind === 65) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 193 && node.parent.kind !== 150)) { + if (!node.parent || (node.parent.kind !== 195 && node.parent.kind !== 152)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -20812,33 +21810,49 @@ var ts; function renameNonTopLevelLetAndConst(node) { if (languageVersion >= 2 || ts.nodeIsSynthesized(node) || - node.kind !== 64 || - (node.parent.kind !== 193 && node.parent.kind !== 150)) { + node.kind !== 65 || + (node.parent.kind !== 195 && node.parent.kind !== 152)) { return; } var combinedFlags = getCombinedFlagsForIdentifier(node); if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { return; } - var list = ts.getAncestor(node, 194); - if (list.parent.kind === 175 && list.parent.parent.kind === 221) { - return; + var list = ts.getAncestor(node, 196); + if (list.parent.kind === 177) { + var isSourceFileLevelBinding = list.parent.parent.kind === 224; + var isModuleLevelBinding = list.parent.parent.kind === 203; + var isFunctionLevelBinding = list.parent.parent.kind === 176 && ts.isFunctionLike(list.parent.parent.parent); + if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { + return; + } } var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var _parent = blockScopeContainer.kind === 221 + var parent = blockScopeContainer.kind === 224 ? blockScopeContainer : blockScopeContainer.parent; - var generatedName = generateUniqueNameForLocation(_parent, node.text); - var variableId = resolver.getBlockScopedVariableId(node); - if (!generatedBlockScopeNames) { - generatedBlockScopeNames = []; + if (resolver.resolvesToSomeValue(parent, node.text)) { + var variableId = resolver.getBlockScopedVariableId(node); + if (!blockScopedVariableToGeneratedName) { + blockScopedVariableToGeneratedName = []; + } + var generatedName = makeUniqueName(node.text); + blockScopedVariableToGeneratedName[variableId] = generatedName; } - generatedBlockScopeNames[variableId] = generatedName; + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + languageVersion >= 2 && + node.parent.kind === 224; } function emitVariableStatement(node) { if (!(node.flags & 1)) { emitStartOfVariableDeclarationList(node.declarationList); } + else if (isES6ExportedDeclaration(node)) { + write("export "); + emitStartOfVariableDeclarationList(node.declarationList); + } emitCommaList(node.declarationList.declarations); write(";"); if (languageVersion < 2 && node.parent === currentSourceFile) { @@ -20848,12 +21862,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var _name = createTempVariable(node); + var name_16 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(_name); - emit(_name); + tempParameters.push(name_16); + emit(name_16); } else { emit(node.name); @@ -20900,7 +21914,7 @@ var ts; if (languageVersion < 2 && ts.hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; - var tempName = createTempVariable(node, "_i").text; + var tempName = createTempVariable(268435456).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -20935,39 +21949,53 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 134 ? "get " : "set "); - emit(node.name); + write(node.kind === 136 ? "get " : "set "); + emit(node.name, false); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 161 && languageVersion >= 2; + return node.kind === 163 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { emitNodeWithoutSourceMap(node.name); } else { - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 162) { + return !!node.name; + } + else if (node.kind === 197) { + return !!node.name || (languageVersion >= 2 && !(node.flags & 256)); } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 134 && node.kind !== 133) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256) { + write("default "); + } + } write("function "); } - if (node.kind === 195 || (node.kind === 160 && node.name)) { + if (shouldEmitFunctionName(node)) { emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 195 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 197 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 134 && node.kind !== 133) { emitTrailingComments(node); } } @@ -20998,13 +22026,12 @@ var ts; emitSignatureParameters(node); } function emitSignatureAndBody(node) { - var saveTempCount = tempCount; + var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; var saveTempParameters = tempParameters; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; tempParameters = undefined; - var popFrame = enterNameScope(); if (shouldEmitAsArrowFunction(node)) { emitSignatureParametersForArrow(node); write(" =>"); @@ -21015,23 +22042,16 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 174) { + else if (node.body.kind === 176) { emitBlockFunctionBody(node, node.body); } else { emitExpressionFunctionBody(node, node.body); } - if (node.flags & 1 && !(node.flags & 256)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); } - exitNameScope(popFrame); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; } @@ -21047,10 +22067,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 158) { + while (current.kind === 160) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 152); + emitParenthesizedIf(body, current.kind === 154); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -21065,7 +22085,7 @@ var ts; write(" "); emitStart(body); write("return "); - emitWithoutComments(body); + emit(body); emitEnd(body); write(";"); emitTempDeclarations(false); @@ -21076,7 +22096,7 @@ var ts; writeLine(); emitLeadingComments(node.body); write("return "); - emitWithoutComments(node.body); + emit(body); write(";"); emitTrailingComments(node.body); emitTempDeclarations(true); @@ -21099,8 +22119,8 @@ var ts; decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; if (preserveNewLines && !preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _i = 0, _a = body.statements, _n = _a.length; _i < _n; _i++) { - var statement = _a[_i]; + for (var _a = 0, _b = body.statements, _c = _b.length; _a < _c; _a++) { + var statement = _b[_a]; write(" "); emit(statement); } @@ -21122,11 +22142,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 177) { + if (statement && statement.kind === 179) { var expr = statement.expression; - if (expr && expr.kind === 155) { + if (expr && expr.kind === 157) { var func = expr.expression; - if (func && func.kind === 90) { + if (func && func.kind === 91) { return statement; } } @@ -21155,7 +22175,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 126) { + else if (memberName.kind === 127) { emitComputedPropertyName(memberName); } else { @@ -21165,7 +22185,7 @@ var ts; } function emitMemberAssignments(node, staticFlag) { ts.forEach(node.members, function (member) { - if (member.kind === 130 && (member.flags & 128) === staticFlag && member.initializer) { + if (member.kind === 132 && (member.flags & 128) === staticFlag && member.initializer) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -21186,20 +22206,17 @@ var ts; } }); } - function emitMemberFunctions(node) { + function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 132 || node.kind === 131) { + if (member.kind === 134 || node.kind === 133) { if (!member.body) { - return emitPinnedOrTripleSlashComments(member); + return emitOnlyPinnedOrTripleSlashComments(member); } writeLine(); emitLeadingComments(member); emitStart(member); emitStart(member.name); - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); @@ -21210,17 +22227,14 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 134 || member.kind === 135) { - var accessors = getAllAccessorDeclarations(node.members, member); + else if (member.kind === 136 || member.kind === 137) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); emitStart(member); write("Object.defineProperty("); emitStart(member.name); - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); @@ -21260,7 +22274,207 @@ var ts; } }); } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members, _c = _b.length; _a < _c; _a++) { + var member = _b[_a]; + if ((member.kind === 134 || node.kind === 133) && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + else if (member.kind === 134 || node.kind === 133 || member.kind === 136 || member.kind === 137) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 136) { + write("get "); + } + else if (member.kind === 137) { + write("set "); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + } + } + function emitConstructor(node, baseTypeNode) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 135 && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + if (member.kind === 132 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeNode) { + write("(...args)"); + } + else { + write("()"); + } + } + } + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeNode) { + var superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeNode); + } + } + emitMemberAssignments(node, 0); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLines(statements); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } function emitClassDeclaration(node) { + if (languageVersion < 2) { + emitClassDeclarationBelowES6(node); + } + else { + emitClassDeclarationForES6AndHigher(node); + } + } + function emitClassDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256) { + write("default "); + } + } + write("class"); + if ((node.name || !(node.flags & 256)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.typeName); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(15, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + if (node.name) { + writeLine(); + write("Object.defineProperty("); + emitDeclarationName(node); + write(", \"name\", { value: \""); + emitDeclarationName(node); + write("\", configurable: true });"); + writeLine(); + } + } + writeLine(); + emitMemberAssignments(node, 128); + emitDecoratorsOfClass(node); + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 256) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassDeclarationBelowES6(node) { write("var "); emitDeclarationName(node); write(" = (function ("); @@ -21269,6 +22483,14 @@ var ts; write("_super"); } write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; increaseIndent(); scopeEmitStart(node); if (baseTypeNode) { @@ -21280,15 +22502,22 @@ var ts; emitEnd(baseTypeNode); } writeLine(); - emitConstructorOfClass(); - emitMemberFunctions(node); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); emitMemberAssignments(node, 128); writeLine(); + emitDecoratorsOfClass(node); + writeLine(); emitToken(15, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); emitToken(15, node.members.end); @@ -21300,94 +22529,147 @@ var ts; } write(");"); emitEnd(node); - if (node.flags & 1 && !(node.flags & 256)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } + emitExportMemberAssignment(node); if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - function emitConstructorOfClass() { - var saveTempCount = tempCount; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempCount = 0; - tempVariables = undefined; - tempParameters = undefined; - var popFrame = enterNameScope(); - ts.forEach(node.members, function (member) { - if (member.kind === 133 && !member.body) { - emitPinnedOrTripleSlashComments(member); - } - }); - var ctor = getFirstConstructorWithBody(node); - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeNode) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("_super.apply(this, arguments);"); - emitEnd(baseTypeNode); - } - } - emitMemberAssignments(node, 0); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) - statements = statements.slice(1); - emitLines(statements); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - exitNameScope(popFrame); - tempCount = saveTempCount; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); } } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var constructor = ts.getFirstConstructorWithBody(node); + if (constructor) { + emitDecoratorsOfParameters(node, constructor); + } + if (!ts.nodeIsDecorated(node)) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = "); + emitDecorateStart(node.decorators); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + ts.forEach(node.members, function (member) { + if ((member.flags & 128) !== staticFlag) { + return; + } + var decorators; + switch (member.kind) { + case 134: + emitDecoratorsOfParameters(node, member); + decorators = member.decorators; + break; + case 136: + case 137: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + return; + } + if (accessors.setAccessor) { + emitDecoratorsOfParameters(node, accessors.setAccessor); + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + break; + case 132: + decorators = member.decorators; + break; + default: + return; + } + if (!decorators) { + return; + } + writeLine(); + emitStart(member); + if (member.kind !== 132) { + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", "); + } + emitDecorateStart(decorators); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (member.kind !== 132) { + write(", Object.getOwnPropertyDescriptor("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write("))"); + } + write(");"); + emitEnd(member); + writeLine(); + }); + } + function emitDecoratorsOfParameters(node, member) { + ts.forEach(member.parameters, function (parameter, parameterIndex) { + if (!ts.nodeIsDecorated(parameter)) { + return; + } + writeLine(); + emitStart(parameter); + emitDecorateStart(parameter.decorators); + emitStart(parameter.name); + if (member.kind === 135) { + emitDeclarationName(node); + write(", void 0"); + } + else { + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + } + write(", "); + write(String(parameterIndex)); + emitEnd(parameter.name); + write(");"); + emitEnd(parameter); + writeLine(); + }); + } + function emitDecorateStart(decorators) { + write("__decorate(["); + var decoratorCount = decorators.length; + for (var i = 0; i < decoratorCount; i++) { + if (i > 0) { + write(", "); + } + var decorator = decorators[i]; + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + } + write("], "); + } function emitInterfaceDeclaration(node) { - emitPinnedOrTripleSlashComments(node); + emitOnlyPinnedOrTripleSlashComments(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -21397,8 +22679,11 @@ var ts; if (!shouldEmitEnumDeclaration(node)) { return; } - if (!(node.flags & 1)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); emitEnd(node); @@ -21408,7 +22693,7 @@ var ts; emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") {"); increaseIndent(); @@ -21424,7 +22709,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (node.flags & 1) { + if (!isES6ExportedDeclaration(node) && node.flags & 1) { writeLine(); emitStart(node); write("var "); @@ -21441,9 +22726,9 @@ var ts; function emitEnumMember(node) { var enumParent = node.parent; emitStart(node); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); emitExpressionForPropertyName(node.name); write("] = "); @@ -21454,14 +22739,12 @@ var ts; write(";"); } function writeEnumMemberDeclarationValue(member) { - if (!member.initializer || ts.isConst(member.parent)) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; } - if (member.initializer) { + else if (member.initializer) { emit(member.initializer); } else { @@ -21469,7 +22752,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 200) { + if (moduleDeclaration.body.kind === 202) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -21480,9 +22763,12 @@ var ts; function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); write(";"); @@ -21491,18 +22777,16 @@ var ts; emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 201) { - var saveTempCount = tempCount; + if (node.body.kind === 203) { + var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; - var popFrame = enterNameScope(); emit(node.body); - exitNameScope(popFrame); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; } else { @@ -21519,7 +22803,7 @@ var ts; scopeEmitEnd(); } write(")("); - if (node.flags & 1) { + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -21528,7 +22812,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (languageVersion < 2 && node.name.kind === 64 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 65 && node.parent === currentSourceFile) { emitExportMemberAssignments(node.name); } } @@ -21539,199 +22823,303 @@ var ts; emitLiteral(moduleName); emitEnd(moduleName); emitToken(17, moduleName.end); - write(";"); } else { - write("require();"); + write("require()"); } } + function getNamespaceDeclarationNode(node) { + if (node.kind === 205) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 208) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 206 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } function emitImportDeclaration(node) { - var info = getExternalImportInfo(node); - if (info) { - var declarationNode = info.declarationNode; - var namedImports = info.namedImports; + if (languageVersion < 2) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 208) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 205 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); emitStart(node); - var moduleName = ts.getExternalModuleName(node); - if (declarationNode) { - if (!(declarationNode.flags & 1)) + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) write("var "); - emitModuleMemberName(declarationNode); + emitModuleMemberName(namespaceDeclaration); write(" = "); - emitRequire(moduleName); - } - else if (namedImports) { - write("var "); - write(resolver.getGeneratedNameForNode(node)); - write(" = "); - emitRequire(moduleName); } else { - emitRequire(moduleName); + var isNakedImport = 206 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } else { - if (declarationNode) { - if (declarationNode.flags & 1) { - emitModuleMemberName(declarationNode); - write(" = "); - emit(declarationNode.name); - write(";"); - } + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); } } } function emitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitImportDeclaration(node); + emitExternalImportDeclaration(node); return; } if (resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (!(node.flags & 1)) + if (isES6ExportedDeclaration(node)) { + write("export "); write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } } function emitExportDeclaration(node) { - if (node.moduleSpecifier) { - emitStart(node); - var generatedName = resolver.getGeneratedNameForNode(node); - if (compilerOptions.module !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - } - if (node.exportClause) { - ts.forEach(node.exportClause.elements, function (specifier) { + if (languageVersion < 2) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (compilerOptions.module !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements, _c = _b.length; _a < _c; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write("__export("); + if (compilerOptions.module !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + emitStart(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emitNodeWithoutSourceMap(node.moduleSpecifier); + } + write(";"); + emitEnd(node); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(languageVersion >= 2); + var needsComma = false; + for (var _a = 0, _b = specifiers.length; _a < _b; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + emitStart(specifier); + if (specifier.propertyName) { + emitNodeWithoutSourceMap(specifier.propertyName); + write(" as "); + } + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (languageVersion >= 2) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 197 && + expression.kind !== 198) { write(";"); - emitEnd(specifier); - }); + } + emitEnd(node); } else { - var tempName = createTempVariable(node).text; writeLine(); - write("for (var " + tempName + " in " + generatedName + ") if (!"); + emitStart(node); emitContainingModuleName(node); - write(".hasOwnProperty(" + tempName + ")) "); - emitContainingModuleName(node); - write("[" + tempName + "] = " + generatedName + "[" + tempName + "];"); - } - emitEnd(node); - } - } - function createExternalImportInfo(node) { - if (node.kind === 203) { - if (node.moduleReference.kind === 213) { - return { - rootNode: node, - declarationNode: node - }; - } - } - else if (node.kind === 204) { - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - return { - rootNode: node, - declarationNode: importClause - }; - } - if (importClause.namedBindings.kind === 206) { - return { - rootNode: node, - declarationNode: importClause.namedBindings - }; - } - return { - rootNode: node, - namedImports: importClause.namedBindings, - localName: resolver.getGeneratedNameForNode(node) - }; - } - return { - rootNode: node - }; - } - else if (node.kind === 210) { - if (node.moduleSpecifier) { - return { - rootNode: node - }; + write(".default = "); + emit(node.expression); + write(";"); + emitEnd(node); } } } - function createExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile) { externalImports = []; exportSpecifiers = {}; - exportDefault = undefined; - ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 210 && !node.moduleSpecifier) { - ts.forEach(node.exportClause.elements, function (specifier) { - if (specifier.name.text === "default") { - exportDefault = exportDefault || specifier; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements, _c = _b.length; _a < _c; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 206: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); } - var _name = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[_name] || (exportSpecifiers[_name] = [])).push(specifier); - }); - } - else if (node.kind === 209) { - exportDefault = exportDefault || node; - } - else if (node.kind === 195 || node.kind === 196) { - if (node.flags & 1 && node.flags & 256) { - exportDefault = exportDefault || node; - } - } - else { - var info = createExternalImportInfo(node); - if (info) { - if ((!info.declarationNode && !info.namedImports) || resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(info); + break; + case 205: + if (node.moduleReference.kind === 216 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); } - } - } - }); - } - function getExternalImportInfo(node) { - if (externalImports) { - for (var _i = 0, _n = externalImports.length; _i < _n; _i++) { - var info = externalImports[_i]; - if (info.rootNode === node) { - return info; - } + break; + case 212: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _d = 0, _e = node.exportClause.elements, _f = _e.length; _d < _f; _d++) { + var specifier = _e[_d]; + var name_17 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_17] || (exportSpecifiers[name_17] = [])).push(specifier); + } + } + break; + case 211: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; } } } - function getFirstExportAssignment(sourceFile) { - return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 209) { - return node; - } - }); - } function sortAMDModules(amdModules) { return amdModules.sort(function (moduleA, moduleB) { if (moduleA.name === moduleB.name) { @@ -21745,7 +23133,20 @@ var ts; } }); } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); writeLine(); write("define("); sortAMDModules(node.amdDependencies); @@ -21753,69 +23154,78 @@ var ts; write("\"" + node.amdModuleName + "\", "); } write("[\"require\", \"exports\""); - ts.forEach(externalImports, function (info) { + for (var _a = 0, _b = externalImports.length; _a < _b; _a++) { + var importNode = externalImports[_a]; write(", "); - var moduleName = ts.getExternalModuleName(info.rootNode); + var moduleName = ts.getExternalModuleName(importNode); if (moduleName.kind === 8) { emitLiteral(moduleName); } else { write("\"\""); } - }); - ts.forEach(node.amdDependencies, function (amdDependency) { + } + for (var _c = 0, _d = node.amdDependencies, _e = _d.length; _c < _e; _c++) { + var amdDependency = _d[_c]; var text = "\"" + amdDependency.path + "\""; write(", "); write(text); - }); + } write("], function (require, exports"); - ts.forEach(externalImports, function (info) { + for (var _f = 0, _g = externalImports.length; _f < _g; _f++) { + var importNode = externalImports[_f]; write(", "); - if (info.declarationNode) { - emit(info.declarationNode.name); + var namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + emit(namespaceDeclaration.name); } else { - write(resolver.getGeneratedNameForNode(info.rootNode)); + write(getGeneratedNameForNode(importNode)); } - }); - ts.forEach(node.amdDependencies, function (amdDependency) { + } + for (var _h = 0, _j = node.amdDependencies, _k = _j.length; _h < _k; _h++) { + var amdDependency = _j[_h]; if (amdDependency.name) { write(", "); write(amdDependency.name); } - }); + } write(") {"); increaseIndent(); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - emitExportDefault(node, true); + emitExportEquals(true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + collectExternalModuleInfo(node); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - emitExportDefault(node, false); + emitExportEquals(false); } - function emitExportDefault(sourceFile, emitAsReturn) { - if (exportDefault && resolver.hasExportDefaultValue(sourceFile)) { + function emitES6Module(node, startIndex) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { writeLine(); - emitStart(exportDefault); + emitStart(exportEquals); write(emitAsReturn ? "return " : "module.exports = "); - if (exportDefault.kind === 209) { - emit(exportDefault.expression); - } - else if (exportDefault.kind === 212) { - emit(exportDefault.propertyName); - } - else { - emitDeclarationName(exportDefault); - } + emit(exportEquals.expression); write(";"); - emitEnd(exportDefault); + emitEnd(exportEquals); } } function emitDirectivePrologues(statements, startWithNewLine) { @@ -21832,11 +23242,21 @@ var ts; } return statements.length; } + function writeHelper(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } function emitSourceFileNode(node) { writeLine(); emitDetachedComments(node); var startIndex = emitDirectivePrologues(node.statements, false); - if (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLine(); write("var __extends = this.__extends || function (d, b) {"); increaseIndent(); @@ -21853,9 +23273,15 @@ var ts; write("};"); extendsEmitted = true; } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { + writeHelper("\nvar __decorate = this.__decorate || function (decorators, target, key, value) {\n var kind = typeof (arguments.length == 2 ? value = target : value);\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n switch (kind) {\n case \"function\": value = decorator(value) || value; break;\n case \"number\": decorator(target, key, value); break;\n case \"undefined\": decorator(target, key); break;\n case \"object\": value = decorator(target, key, value) || value; break;\n }\n }\n return value;\n};"); + decorateEmitted = true; + } if (ts.isExternalModule(node)) { - createExternalModuleInfo(node); - if (compilerOptions.module === 2) { + if (languageVersion >= 2) { + emitES6Module(node, startIndex); + } + else if (compilerOptions.module === 2) { emitAMDModule(node, startIndex); } else { @@ -21865,75 +23291,75 @@ var ts; else { externalImports = undefined; exportSpecifiers = undefined; - exportDefault = undefined; + exportEquals = undefined; + hasExportStars = false; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMapWithComments(node) { + function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { if (!node) { return; } if (node.flags & 2) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } - var _emitComments = shouldEmitLeadingAndTrailingComments(node); - if (_emitComments) { + var emitComments = shouldEmitLeadingAndTrailingComments(node); + if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node); - if (_emitComments) { + emitJavaScriptWorker(node, allowGeneratedIdentifiers); + if (emitComments) { emitTrailingComments(node); } } - function emitNodeWithoutSourceMapWithoutComments(node) { - if (!node) { - return; - } - if (node.flags & 2) { - return emitPinnedOrTripleSlashComments(node); - } - emitJavaScriptWorker(node); - } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 197: - case 195: - case 204: - case 203: - case 198: - case 209: - return false; - case 200: - return shouldEmitModuleDeclaration(node); case 199: + case 197: + case 206: + case 205: + case 200: + case 211: + return false; + case 202: + return shouldEmitModuleDeclaration(node); + case 201: return shouldEmitEnumDeclaration(node); } + if (node.kind !== 176 && + node.parent && + node.parent.kind === 163 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } return true; } - function emitJavaScriptWorker(node) { + function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } switch (node.kind) { - case 64: - return emitIdentifier(node); - case 128: + case 65: + return emitIdentifier(node, allowGeneratedIdentifiers); + case 129: return emitParameter(node); - case 132: - case 131: - return emitMethod(node); case 134: - case 135: + case 133: + return emitMethod(node); + case 136: + case 137: return emitAccessor(node); - case 92: + case 93: return emitThis(node); - case 90: + case 91: return emitSuper(node); - case 88: + case 89: return write("null"); - case 94: + case 95: return write("true"); - case 79: + case 80: return write("false"); case 7: case 8: @@ -21943,125 +23369,127 @@ var ts; case 12: case 13: return emitLiteral(node); - case 169: - return emitTemplateExpression(node); - case 173: - return emitTemplateSpan(node); - case 125: - return emitQualifiedName(node); - case 148: - return emitObjectBindingPattern(node); - case 149: - return emitArrayBindingPattern(node); - case 150: - return emitBindingElement(node); - case 151: - return emitArrayLiteral(node); - case 152: - return emitObjectLiteral(node); - case 218: - return emitPropertyAssignment(node); - case 219: - return emitShorthandPropertyAssignment(node); - case 126: - return emitComputedPropertyName(node); - case 153: - return emitPropertyAccess(node); - case 154: - return emitIndexedAccess(node); - case 155: - return emitCallExpression(node); - case 156: - return emitNewExpression(node); - case 157: - return emitTaggedTemplateExpression(node); - case 158: - return emit(node.expression); - case 159: - return emitParenExpression(node); - case 195: - case 160: - case 161: - return emitFunctionDeclaration(node); - case 162: - return emitDeleteExpression(node); - case 163: - return emitTypeOfExpression(node); - case 164: - return emitVoidExpression(node); - case 165: - return emitPrefixUnaryExpression(node); - case 166: - return emitPostfixUnaryExpression(node); - case 167: - return emitBinaryExpression(node); - case 168: - return emitConditionalExpression(node); case 171: - return emitSpreadElementExpression(node); - case 172: - return; - case 174: - case 201: - return emitBlock(node); + return emitTemplateExpression(node); case 175: - return emitVariableStatement(node); - case 176: - return write(";"); - case 177: - return emitExpressionStatement(node); - case 178: - return emitIfStatement(node); - case 179: - return emitDoStatement(node); - case 180: - return emitWhileStatement(node); - case 181: - return emitForStatement(node); - case 183: - case 182: - return emitForInOrForOfStatement(node); - case 184: - case 185: - return emitBreakOrContinueStatement(node); - case 186: - return emitReturnStatement(node); - case 187: - return emitWithStatement(node); - case 188: - return emitSwitchStatement(node); - case 214: - case 215: - return emitCaseOrDefaultClause(node); - case 189: - return emitLabelledStatement(node); - case 190: - return emitThrowStatement(node); - case 191: - return emitTryStatement(node); - case 217: - return emitCatchClause(node); - case 192: - return emitDebuggerStatement(node); - case 193: - return emitVariableDeclaration(node); - case 196: - return emitClassDeclaration(node); - case 197: - return emitInterfaceDeclaration(node); - case 199: - return emitEnumDeclaration(node); - case 220: - return emitEnumMember(node); - case 200: - return emitModuleDeclaration(node); - case 204: - return emitImportDeclaration(node); - case 203: - return emitImportEqualsDeclaration(node); - case 210: - return emitExportDeclaration(node); + return emitTemplateSpan(node); + case 126: + return emitQualifiedName(node); + case 150: + return emitObjectBindingPattern(node); + case 151: + return emitArrayBindingPattern(node); + case 152: + return emitBindingElement(node); + case 153: + return emitArrayLiteral(node); + case 154: + return emitObjectLiteral(node); case 221: + return emitPropertyAssignment(node); + case 222: + return emitShorthandPropertyAssignment(node); + case 127: + return emitComputedPropertyName(node); + case 155: + return emitPropertyAccess(node); + case 156: + return emitIndexedAccess(node); + case 157: + return emitCallExpression(node); + case 158: + return emitNewExpression(node); + case 159: + return emitTaggedTemplateExpression(node); + case 160: + return emit(node.expression); + case 161: + return emitParenExpression(node); + case 197: + case 162: + case 163: + return emitFunctionDeclaration(node); + case 164: + return emitDeleteExpression(node); + case 165: + return emitTypeOfExpression(node); + case 166: + return emitVoidExpression(node); + case 167: + return emitPrefixUnaryExpression(node); + case 168: + return emitPostfixUnaryExpression(node); + case 169: + return emitBinaryExpression(node); + case 170: + return emitConditionalExpression(node); + case 173: + return emitSpreadElementExpression(node); + case 174: + return; + case 176: + case 203: + return emitBlock(node); + case 177: + return emitVariableStatement(node); + case 178: + return write(";"); + case 179: + return emitExpressionStatement(node); + case 180: + return emitIfStatement(node); + case 181: + return emitDoStatement(node); + case 182: + return emitWhileStatement(node); + case 183: + return emitForStatement(node); + case 185: + case 184: + return emitForInOrForOfStatement(node); + case 186: + case 187: + return emitBreakOrContinueStatement(node); + case 188: + return emitReturnStatement(node); + case 189: + return emitWithStatement(node); + case 190: + return emitSwitchStatement(node); + case 217: + case 218: + return emitCaseOrDefaultClause(node); + case 191: + return emitLabelledStatement(node); + case 192: + return emitThrowStatement(node); + case 193: + return emitTryStatement(node); + case 220: + return emitCatchClause(node); + case 194: + return emitDebuggerStatement(node); + case 195: + return emitVariableDeclaration(node); + case 198: + return emitClassDeclaration(node); + case 199: + return emitInterfaceDeclaration(node); + case 201: + return emitEnumDeclaration(node); + case 223: + return emitEnumMember(node); + case 202: + return emitModuleDeclaration(node); + case 206: + return emitImportDeclaration(node); + case 205: + return emitImportEqualsDeclaration(node); + case 212: + return emitExportDeclaration(node); + case 211: + return emitExportAssignment(node); + case 224: return emitSourceFileNode(node); } } @@ -22078,34 +23506,50 @@ var ts; } return leadingComments; } + function filterComments(ranges, onlyPinnedOrTripleSlashComments) { + if (ranges && onlyPinnedOrTripleSlashComments) { + ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); + if (ranges.length === 0) { + return undefined; + } + } + return ranges; + } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 221 || node.pos !== node.parent.pos) { - var leadingComments; + if (node.parent.kind === 224 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); + return getLeadingCommentsWithoutDetachedComments(); } else { - leadingComments = ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); } - return leadingComments; } } } - function emitLeadingDeclarationComments(node) { - var leadingComments = getLeadingCommentsToEmit(node); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingDeclarationComments(node) { + function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 221 || node.end !== node.parent.end) { - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + if (node.parent.kind === 224 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitLeadingCommentsOfLocalPosition(pos) { + function emitOnlyPinnedOrTripleSlashComments(node) { + emitLeadingCommentsWorker(node, true); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + } + function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { + var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitLeadingCommentsOfPosition(pos) { var leadingComments; if (hasDetachedComments(pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -22113,18 +23557,19 @@ var ts; else { leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + leadingComments = filterComments(leadingComments, compilerOptions.removeComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } - function emitDetachedCommentsAtPosition(node) { + function emitDetachedComments(node) { var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); if (leadingComments) { var detachedComments = []; var lastComment; ts.forEach(leadingComments, function (comment) { if (lastComment) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); if (commentLine >= lastCommentLine + 2) { return detachedComments; } @@ -22133,11 +23578,11 @@ var ts; lastComment = comment; }); if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); - var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -22149,54 +23594,53 @@ var ts; } } } - function emitPinnedOrTripleSlashComments(node) { - var pinnedComments = ts.filter(getLeadingCommentsToEmit(node), isPinnedOrTripleSlashComment); - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; - } + function isPinnedOrTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && + currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { + return true; } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments); - emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment); - } - } - function writeDeclarationFile(jsFilePath, sourceFile) { - var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput; - var appliedSyncOutputPos = 0; - ts.forEach(emitDeclarationResult.aliasDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += aliasEmitInfo.asynchronousOutput; - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos); - writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); if (compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); } } } ts.emitFiles = emitFiles; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { + ts.programTime = 0; ts.emitTime = 0; ts.ioReadTime = 0; + ts.ioWriteTime = 0; ts.version = "1.5.0.0"; - function createCompilerHost(options) { + function findConfigFile(searchPath) { + var fileName = "tsconfig.json"; + while (true) { + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; function getCanonicalFileName(fileName) { @@ -22218,29 +23662,31 @@ var ts; } text = ""; } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined; + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } } function writeFile(fileName, data, writeByteOrderMark, onError) { - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } try { + var start = new Date().getTime(); ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); ts.sys.writeFile(fileName, data, writeByteOrderMark); + ts.ioWriteTime += new Date().getTime() - start; } catch (e) { if (onError) { @@ -22261,6 +23707,9 @@ var ts; ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program) { var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics()); + } return ts.sortAndDeduplicateDiagnostics(diagnostics); } ts.getPreEmitDiagnostics = getPreEmitDiagnostics; @@ -22294,14 +23743,16 @@ var ts; var diagnostics = ts.createDiagnosticCollection(); var seenNoDefaultLib = options.noLib; var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var start = new Date().getTime(); host = host || createCompilerHost(options); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); if (!seenNoDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; + ts.programTime += new Date().getTime() - start; program = { getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, @@ -22339,10 +23790,6 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function getDeclarationDiagnostics(targetSourceFile) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(targetSourceFile); - return ts.getDeclarationDiagnostics(getEmitHost(), resolver, targetSourceFile); - } function emit(sourceFile, writeFileCallback) { if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; @@ -22373,6 +23820,9 @@ var ts; function getSemanticDiagnostics(sourceFile) { return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); } + function getDeclarationDiagnostics(sourceFile) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + } function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } @@ -22384,6 +23834,13 @@ var ts; var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); } + function getDeclarationDiagnosticsForFile(sourceFile) { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + var writeFile = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + } + } function getGlobalDiagnostics() { var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; @@ -22399,10 +23856,10 @@ var ts; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var start; - var _length; + var length; if (refEnd !== undefined && refPos !== undefined) { start = refPos; - _length = refEnd - refPos; + length = refEnd - refPos; } var diagnostic; if (hasExtension(fileName)) { @@ -22427,7 +23884,7 @@ var ts; } if (diagnostic) { if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, start, _length, diagnostic, fileName)); + diagnostics.add(ts.createFileDiagnostic(refFile, start, length, diagnostic, fileName)); } else { diagnostics.add(ts.createCompilerDiagnostic(diagnostic, fileName)); @@ -22471,14 +23928,14 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var _file = filesByName[canonicalName]; - if (_file && host.useCaseSensitiveFileNames()) { - var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(_file.fileName, host.getCurrentDirectory()) : _file.fileName; + var file = filesByName[canonicalName]; + if (file && host.useCaseSensitiveFileNames()) { + var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } } - return _file; + return file; } } function processReferencedFiles(file, basePath) { @@ -22489,7 +23946,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 204 || node.kind === 203 || node.kind === 210) { + if (node.kind === 206 || node.kind === 205 || node.kind === 212) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -22509,17 +23966,17 @@ var ts; } } } - else if (node.kind === 200 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 202 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { - var _searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - var tsFile = findModuleSourceFile(_searchName + ".ts", nameLiteral); + var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); + var tsFile = findModuleSourceFile(searchName + ".ts", nameLiteral); if (!tsFile) { - findModuleSourceFile(_searchName + ".d.ts", nameLiteral); + findModuleSourceFile(searchName + ".d.ts", nameLiteral); } } } @@ -22540,10 +23997,16 @@ var ts; } return; } + var languageVersion = options.target || 0; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (firstExternalModuleSourceFile && !options.module) { - var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + if (!options.module && languageVersion < 2) { + var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + } + } + if (options.module && languageVersion >= 2) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); } if (options.outDir || options.sourceRoot || @@ -22592,6 +24055,9 @@ var ts; } ts.createProgram = createProgram; })(ts || (ts = {})); +// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. +// See LICENSE.txt in the project root for complete license information. +/// var ts; (function (ts) { var BreakpointResolver; @@ -22630,98 +24096,101 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return spanInPreviousNode(node); } - if (node.parent.kind === 181) { + if (node.parent.kind === 183) { return textSpan(node); } - if (node.parent.kind === 167 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 169 && node.parent.operatorToken.kind === 23) { return textSpan(node); } - if (node.parent.kind == 161 && node.parent.body == node) { + if (node.parent.kind == 163 && node.parent.body == node) { return textSpan(node); } } switch (node.kind) { - case 175: + case 177: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 193: - case 130: - case 129: - return spanInVariableDeclaration(node); - case 128: - return spanInParameterDeclaration(node); case 195: case 132: case 131: + return spanInVariableDeclaration(node); + case 129: + return spanInParameterDeclaration(node); + case 197: case 134: - case 135: case 133: - case 160: - case 161: + case 136: + case 137: + case 135: + case 162: + case 163: return spanInFunctionDeclaration(node); - case 174: + case 176: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 201: + case 203: return spanInBlock(node); - case 217: + case 220: return spanInBlock(node.block); - case 177: + case 179: return textSpan(node.expression); - case 186: + case 188: return textSpan(node.getChildAt(0), node.expression); + case 182: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 181: + return spanInNode(node.statement); + case 194: + return textSpan(node.getChildAt(0)); case 180: return textSpan(node, ts.findNextToken(node.expression, node)); - case 179: - return spanInNode(node.statement); - case 192: - return textSpan(node.getChildAt(0)); - case 178: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 189: - return spanInNode(node.statement); - case 185: - case 184: - return textSpan(node.getChildAt(0), node.label); - case 181: - return spanInForStatement(node); - case 182: - case 183: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 188: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 214: - case 215: - return spanInNode(node.statements[0]); case 191: - return spanInBlock(node.tryBlock); + return spanInNode(node.statement); + case 187: + case 186: + return textSpan(node.getChildAt(0), node.label); + case 183: + return spanInForStatement(node); + case 184: + case 185: + return textSpan(node, ts.findNextToken(node.expression, node)); case 190: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 217: + case 218: + return spanInNode(node.statements[0]); + case 193: + return spanInBlock(node.tryBlock); + case 192: return textSpan(node, node.expression); - case 209: + case 211: + if (!node.expression) { + return undefined; + } return textSpan(node, node.expression); - case 203: + case 205: return textSpan(node, node.moduleReference); - case 204: + case 206: return textSpan(node, node.moduleSpecifier); - case 210: + case 212: return textSpan(node, node.moduleSpecifier); - case 200: + case 202: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 196: - case 199: - case 220: - case 155: - case 156: - return textSpan(node); - case 187: - return spanInNode(node.statement); - case 197: case 198: + case 201: + case 223: + case 157: + case 158: + return textSpan(node); + case 189: + return spanInNode(node.statement); + case 199: + case 200: return undefined; case 22: case 1: @@ -22741,17 +24210,17 @@ var ts; case 25: case 24: return spanInGreaterThanOrLessThanToken(node); - case 99: + case 100: return spanInWhileKeyword(node); - case 75: - case 67: - case 80: + case 76: + case 68: + case 81: return spanInNextNode(node); default: - if (node.parent.kind === 218 && node.parent.name === node) { + if (node.parent.kind === 221 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 158 && node.parent.type === node) { + if (node.parent.kind === 160 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -22761,12 +24230,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 182 || - variableDeclaration.parent.parent.kind === 183) { + if (variableDeclaration.parent.parent.kind === 184 || + variableDeclaration.parent.parent.kind === 185) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 175; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 181 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 177; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 183 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -22812,7 +24281,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 196 && functionDeclaration.kind !== 133); + (functionDeclaration.parent.kind === 198 && functionDeclaration.kind !== 135); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -22832,23 +24301,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 200: + case 202: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 180: - case 178: case 182: - case 183: + case 180: + case 184: + case 185: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 181: + case 183: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 194) { + if (forStatement.initializer.kind === 196) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -22867,34 +24336,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 199: + case 201: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 196: + case 198: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 202: + case 204: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 201: + case 203: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 199: - case 196: + case 201: + case 198: return textSpan(node); - case 174: + case 176: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 217: + case 220: return spanInNode(node.parent.statements[node.parent.statements.length - 1]); ; - case 202: + case 204: var caseBlock = node.parent; var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1]; if (lastClause) { @@ -22906,24 +24375,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 160: - case 195: - case 161: - case 132: - case 131: + case 162: + case 197: + case 163: case 134: - case 135: case 133: - case 180: - case 179: + case 136: + case 137: + case 135: + case 182: case 181: + case 183: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -22931,19 +24400,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 218) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 221) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 158) { + if (node.parent.kind === 160) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -22953,6 +24422,20 @@ var ts; BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// var ts; (function (ts) { var OutliningElementsCollector; @@ -22972,7 +24455,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 161; + return ts.isFunctionBlock(node) && node.parent.kind !== 163; } var depth = 0; var maxDepth = 20; @@ -22981,30 +24464,30 @@ var ts; return; } switch (n.kind) { - case 174: + case 176: if (!ts.isFunctionBlock(n)) { - var _parent = n.parent; + var parent_6 = n.parent; var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (_parent.kind === 179 || - _parent.kind === 182 || - _parent.kind === 183 || - _parent.kind === 181 || - _parent.kind === 178 || - _parent.kind === 180 || - _parent.kind === 187 || - _parent.kind === 217) { - addOutliningSpan(_parent, openBrace, closeBrace, autoCollapse(n)); + if (parent_6.kind === 181 || + parent_6.kind === 184 || + parent_6.kind === 185 || + parent_6.kind === 183 || + parent_6.kind === 180 || + parent_6.kind === 182 || + parent_6.kind === 189 || + parent_6.kind === 220) { + addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } - if (_parent.kind === 191) { - var tryStatement = _parent; + if (parent_6.kind === 193) { + var tryStatement = parent_6; if (tryStatement.tryBlock === n) { - addOutliningSpan(_parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 80, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 81, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -23020,23 +24503,23 @@ var ts; }); break; } - case 201: { - var _openBrace = ts.findChildOfKind(n, 14, sourceFile); - var _closeBrace = ts.findChildOfKind(n, 15, sourceFile); - addOutliningSpan(n.parent, _openBrace, _closeBrace, autoCollapse(n)); + case 203: { + var openBrace = ts.findChildOfKind(n, 14, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 196: - case 197: + case 198: case 199: - case 152: - case 202: { - var _openBrace_1 = ts.findChildOfKind(n, 14, sourceFile); - var _closeBrace_1 = ts.findChildOfKind(n, 15, sourceFile); - addOutliningSpan(n, _openBrace_1, _closeBrace_1, autoCollapse(n)); + case 201: + case 154: + case 204: { + var openBrace = ts.findChildOfKind(n, 14, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 151: + case 153: var openBracket = ts.findChildOfKind(n, 18, sourceFile); var closeBracket = ts.findChildOfKind(n, 19, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -23107,9 +24590,9 @@ var ts; if (result !== undefined) { return result; } - if (declaration.name.kind === 126) { + if (declaration.name.kind === 127) { var expr = declaration.name.expression; - if (expr.kind === 153) { + if (expr.kind === 155) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -23117,7 +24600,7 @@ var ts; return undefined; } function getTextOfIdentifierOrLiteral(node) { - if (node.kind === 64 || + if (node.kind === 65 || node.kind === 8 || node.kind === 7) { return node.text; @@ -23130,7 +24613,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 126) { + else if (declaration.name.kind === 127) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -23147,7 +24630,7 @@ var ts; } return true; } - if (expression.kind === 153) { + if (expression.kind === 155) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -23158,7 +24641,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 126) { + if (declaration.name.kind === 127) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -23174,15 +24657,15 @@ var ts; } function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); - var _bestMatchKind = 3; + var bestMatchKind = ts.PatternMatchKind.camelCase; for (var _i = 0, _n = matches.length; _i < _n; _i++) { var match = matches[_i]; var kind = match.kind; - if (kind < _bestMatchKind) { - _bestMatchKind = kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; } } - return _bestMatchKind; + return bestMatchKind; } var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { @@ -23209,6 +24692,7 @@ var ts; NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { var NavigationBar; @@ -23221,14 +24705,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 200: + case 202: do { current = current.parent; - } while (current.kind === 200); - case 196: + } while (current.kind === 202); + case 198: + case 201: case 199: case 197: - case 195: indent++; } current = current.parent; @@ -23239,26 +24723,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 175: + case 177: ts.forEach(node.declarationList.declarations, visit); break; - case 148: - case 149: + case 150: + case 151: ts.forEach(node.elements, visit); break; - case 210: + case 212: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 204: + case 206: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { childNodes.push(importClause.namedBindings); } else { @@ -23267,20 +24751,20 @@ var ts; } } break; - case 150: - case 193: + case 152: + case 195: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 196: + case 198: + case 201: case 199: + case 202: case 197: - case 200: - case 195: - case 203: - case 208: - case 212: + case 205: + case 210: + case 214: childNodes.push(node); break; } @@ -23315,17 +24799,17 @@ var ts; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var node = nodes[_i]; switch (node.kind) { - case 196: + case 198: + case 201: case 199: - case 197: topLevelNodes.push(node); break; - case 200: + case 202: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 195: + case 197: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -23336,9 +24820,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 195) { - if (functionDeclaration.body && functionDeclaration.body.kind === 174) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 195 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 197) { + if (functionDeclaration.body && functionDeclaration.body.kind === 176) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 197 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -23353,17 +24837,17 @@ var ts; var keyToItem = {}; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var child = nodes[_i]; - var _item = createItem(child); - if (_item !== undefined) { - if (_item.text.length > 0) { - var key = _item.text + "-" + _item.kind + "-" + _item.indent; + var item_3 = createItem(child); + if (item_3 !== undefined) { + if (item_3.text.length > 0) { + var key = item_3.text + "-" + item_3.kind + "-" + item_3.indent; var itemWithSameName = keyToItem[key]; if (itemWithSameName) { - merge(itemWithSameName, _item); + merge(itemWithSameName, item_3); } else { - keyToItem[key] = _item; - items.push(_item); + keyToItem[key] = item_3; + items.push(item_3); } } } @@ -23391,7 +24875,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 128: + case 129: if (ts.isBindingPattern(node.name)) { break; } @@ -23399,34 +24883,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 134: + case 133: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 136: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 137: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 140: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 223: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 138: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 139: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); case 132: case 131: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 134: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 135: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 138: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 220: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 136: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 137: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 130: - case 129: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 195: + case 197: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 193: - case 150: + case 195: + case 152: var variableDeclarationNode; - var _name; - if (node.kind === 150) { - _name = node.name; + var name_18; + if (node.kind === 152) { + name_18 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 193) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 195) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -23434,24 +24918,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - _name = node.name; + name_18 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.variableElement); } - case 133: + case 135: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 212: - case 208: - case 203: + case 214: + case 210: case 205: - case 206: + case 207: + case 208: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -23481,17 +24965,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 221: + case 224: return createSourceFileItem(node); - case 196: + case 198: return createClassItem(node); - case 199: + case 201: return createEnumItem(node); - case 197: + case 199: return createIterfaceItem(node); - case 200: + case 202: return createModuleItem(node); - case 195: + case 197: return createFunctionItem(node); } return undefined; @@ -23501,7 +24985,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 200) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 202) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -23513,9 +24997,9 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.name && node.body && node.body.kind === 174) { + if ((node.name || node.flags & 256) && node.body && node.body.kind === 176) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + return getNavigationBarItem((!node.name && node.flags & 256) ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } return undefined; } @@ -23531,13 +25015,10 @@ var ts; return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); } function createClassItem(node) { - if (!node.name) { - return undefined; - } var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 133 && member; + return member.kind === 135 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -23545,7 +25026,8 @@ var ts; } childItems = getItemsWorker(sortNodes(nodes), createChildItem); } - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + var nodeName = !node.name && (node.flags & 256) ? "default" : node.name.text; + return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createEnumItem(node) { var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); @@ -23557,19 +25039,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 126; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 127; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 200) { + while (node.body.kind === 202) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 221 + return node.kind === 224 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -23651,10 +25133,10 @@ var ts; var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); if (index === 0) { if (chunk.text.length === candidate.length) { - return createPatternMatch(0, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); } else { - return createPatternMatch(1, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -23664,14 +25146,14 @@ var ts; for (var _i = 0, _n = wordSpans.length; _i < _n; _i++) { var span = wordSpans[_i]; if (partStartsWith(candidate, span, chunk.text, true)) { - return createPatternMatch(2, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); } } } } else { if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(2, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); } } if (!isLowercase) { @@ -23679,18 +25161,18 @@ var ts; var candidateParts = getWordSpans(candidate); var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); if (camelCaseWeight !== undefined) { - return createPatternMatch(3, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); } camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); if (camelCaseWeight !== undefined) { - return createPatternMatch(3, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); } } } if (isLowercase) { if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(2, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); } } } @@ -23741,10 +25223,10 @@ var ts; } } else { - for (var _i = 0; _i < patternPartLength; _i++) { - var _ch1 = pattern.charCodeAt(patternPartStart + _i); - var _ch2 = candidate.charCodeAt(candidateSpan.start + _i); - if (_ch1 !== _ch2) { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (ch1 !== ch2) { return false; } } @@ -23819,7 +25301,7 @@ var ts; return result1.kind - result2.kind; } function compareCamelCase(result1, result2) { - if (result1.kind === 3 && result2.kind === 3) { + if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { return result2.camelCaseWeight - result1.camelCaseWeight; } return 0; @@ -24031,6 +25513,7 @@ var ts; return transition; } })(ts || (ts = {})); +/// var ts; (function (ts) { var SignatureHelp; @@ -24055,7 +25538,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 155 || node.parent.kind === 156) { + if (node.parent.kind === 157 || node.parent.kind === 158) { var callExpression = node.parent; if (node.kind === 24 || node.kind === 16) { @@ -24072,43 +25555,43 @@ var ts; } var listItemInfo = ts.findListItemInfo(node); if (listItemInfo) { - var _list = listItemInfo.list; - var _isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === _list.pos; - var argumentIndex = getArgumentIndex(_list, node); - var argumentCount = getArgumentCount(_list); + var list = listItemInfo.list; + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + var argumentIndex = getArgumentIndex(list, node); + var argumentCount = getArgumentCount(list); ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); return { - kind: _isTypeArgList ? 0 : 1, + kind: isTypeArgList ? 0 : 1, invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(_list), + argumentsSpan: getApplicableSpanForArguments(list), argumentIndex: argumentIndex, argumentCount: argumentCount }; } } - else if (node.kind === 10 && node.parent.kind === 157) { + else if (node.kind === 10 && node.parent.kind === 159) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 157) { + else if (node.kind === 11 && node.parent.parent.kind === 159) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 169); - var _argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; - return getArgumentListInfoForTemplate(tagExpression, _argumentIndex); + ts.Debug.assert(templateExpression.kind === 171); + var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 173 && node.parent.parent.parent.kind === 157) { + else if (node.parent.kind === 175 && node.parent.parent.parent.kind === 159) { var templateSpan = node.parent; - var _templateExpression = templateSpan.parent; - var _tagExpression = _templateExpression.parent; - ts.Debug.assert(_templateExpression.kind === 169); + var templateExpression = templateSpan.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 171); if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } - var spanIndex = _templateExpression.templateSpans.indexOf(templateSpan); - var _argumentIndex_1 = getArgumentIndexForTemplatePiece(spanIndex, node); - return getArgumentListInfoForTemplate(_tagExpression, _argumentIndex_1); + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } return undefined; } @@ -24166,7 +25649,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 169) { + if (template.kind === 171) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -24175,16 +25658,16 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 221; n = n.parent) { + for (var n = node; n.kind !== 224; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } if (n.pos < n.parent.pos || n.end > n.parent.end) { ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); } - var _argumentInfo = getImmediatelyContainingArgumentInfo(n); - if (_argumentInfo) { - return _argumentInfo; + var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); + if (argumentInfo_1) { + return argumentInfo_1; } } return undefined; @@ -24347,6 +25830,129 @@ var ts; return start < end; } ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + ts.positionBelongsToNode = positionBelongsToNode; + function isCompletedNode(n, sourceFile) { + if (ts.nodeIsMissing(n)) { + return false; + } + switch (n.kind) { + case 198: + case 199: + case 201: + case 154: + case 150: + case 145: + case 176: + case 203: + case 204: + return nodeEndsWith(n, 15, sourceFile); + case 220: + return isCompletedNode(n.block, sourceFile); + case 158: + if (!n.arguments) { + return true; + } + case 157: + case 161: + case 149: + return nodeEndsWith(n, 17, sourceFile); + case 142: + case 143: + return isCompletedNode(n.type, sourceFile); + case 135: + case 136: + case 137: + case 197: + case 162: + case 134: + case 133: + case 139: + case 138: + case 163: + if (n.body) { + return isCompletedNode(n.body, sourceFile); + } + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 17, sourceFile); + case 202: + return n.body && isCompletedNode(n.body, sourceFile); + case 180: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); + } + return isCompletedNode(n.thenStatement, sourceFile); + case 179: + return isCompletedNode(n.expression, sourceFile); + case 153: + case 151: + case 156: + case 127: + case 147: + return nodeEndsWith(n, 19, sourceFile); + case 140: + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 19, sourceFile); + case 217: + case 218: + return false; + case 183: + case 184: + case 185: + case 182: + return isCompletedNode(n.statement, sourceFile); + case 181: + var hasWhileKeyword = findChildOfKind(n, 100, sourceFile); + if (hasWhileKeyword) { + return nodeEndsWith(n, 17, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + case 144: + return isCompletedNode(n.exprName, sourceFile); + case 165: + case 164: + case 166: + case 172: + case 173: + var unaryWordExpression = n; + return isCompletedNode(unaryWordExpression.expression, sourceFile); + case 159: + return isCompletedNode(n.template, sourceFile); + case 171: + var lastSpan = ts.lastOrUndefined(n.templateSpans); + return isCompletedNode(lastSpan, sourceFile); + case 175: + return ts.nodeIsPresent(n.literal); + case 167: + return isCompletedNode(n.operand, sourceFile); + case 169: + return isCompletedNode(n.right, sourceFile); + case 170: + return isCompletedNode(n.whenFalse, sourceFile); + default: + return true; + } + } + ts.isCompletedNode = isCompletedNode; + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = children[children.length - 1]; + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 22 && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } function findListItemInfo(node) { var list = findContainingList(node); if (!list) { @@ -24360,13 +25966,17 @@ var ts; }; } ts.findListItemInfo = findListItemInfo; + function hasChildOfKind(n, kind, sourceFile) { + return !!findChildOfKind(n, kind, sourceFile); + } + ts.hasChildOfKind = hasChildOfKind; function findChildOfKind(n, kind, sourceFile) { return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); } ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 222 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 225 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -24472,10 +26082,10 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 221); + ts.Debug.assert(startNode !== undefined || n.kind === 224); if (children.length) { - var _candidate = findRightmostChildNodeWithTokens(children, children.length); - return _candidate && findRightmostToken(_candidate); + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); } } function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { @@ -24509,22 +26119,23 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 139 || node.kind === 155) { + if (node.kind === 141 || node.kind === 157) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 196 || node.kind === 197) { + if (ts.isFunctionLike(node) || node.kind === 198 || node.kind === 199) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 124; + return n.kind >= 0 && n.kind <= 125; } ts.isToken = isToken; function isWord(kind) { - return kind === 64 || ts.isKeyword(kind); + return kind === 65 || ts.isKeyword(kind); } + ts.isWord = isWord; function isPropertyName(kind) { return kind === 8 || kind === 7 || isWord(kind); } @@ -24533,7 +26144,7 @@ var ts; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 <= kind && kind <= 63; + return 14 <= kind && kind <= 64; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -24541,6 +26152,16 @@ var ts; && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; + function isAccessibilityModifier(kind) { + switch (kind) { + case 109: + case 107: + case 108: + return true; + } + return false; + } + ts.isAccessibilityModifier = isAccessibilityModifier; function compareDataObjects(dst, src) { for (var e in dst) { if (typeof dst[e] === "object") { @@ -24561,7 +26182,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 128; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 129; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -24572,12 +26193,12 @@ var ts; resetWriter(); return { displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, 5); }, - writeOperator: function (text) { return writeKind(text, 12); }, - writePunctuation: function (text) { return writeKind(text, 15); }, - writeSpace: function (text) { return writeKind(text, 16); }, - writeStringLiteral: function (text) { return writeKind(text, 8); }, - writeParameter: function (text) { return writeKind(text, 13); }, + writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, + writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, + writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, + writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, + writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, writeSymbol: writeSymbol, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -24589,7 +26210,7 @@ var ts; if (lineStart) { var indentString = ts.getIndentString(indent); if (indentString) { - displayParts.push(displayPart(indentString, 16)); + displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); } lineStart = false; } @@ -24617,48 +26238,48 @@ var ts; function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3) { - return isFirstDeclarationOfSymbolParameter(symbol) ? 13 : 9; + return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } else if (flags & 4) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 32768) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 65536) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 8) { - return 19; + return ts.SymbolDisplayPartKind.enumMemberName; } else if (flags & 16) { - return 20; + return ts.SymbolDisplayPartKind.functionName; } else if (flags & 32) { - return 1; + return ts.SymbolDisplayPartKind.className; } else if (flags & 64) { - return 4; + return ts.SymbolDisplayPartKind.interfaceName; } else if (flags & 384) { - return 2; + return ts.SymbolDisplayPartKind.enumName; } else if (flags & 1536) { - return 11; + return ts.SymbolDisplayPartKind.moduleName; } else if (flags & 8192) { - return 10; + return ts.SymbolDisplayPartKind.methodName; } else if (flags & 262144) { - return 18; + return ts.SymbolDisplayPartKind.typeParameterName; } else if (flags & 524288) { - return 0; + return ts.SymbolDisplayPartKind.aliasName; } else if (flags & 8388608) { - return 0; + return ts.SymbolDisplayPartKind.aliasName; } - return 17; + return ts.SymbolDisplayPartKind.text; } } ts.symbolPart = symbolPart; @@ -24670,27 +26291,34 @@ var ts; } ts.displayPart = displayPart; function spacePart() { - return displayPart(" ", 16); + return displayPart(" ", ts.SymbolDisplayPartKind.space); } ts.spacePart = spacePart; function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), 5); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); } ts.keywordPart = keywordPart; function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), 15); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); } ts.punctuationPart = punctuationPart; function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), 12); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); } ts.operatorPart = operatorPart; + function textOrKeywordPart(text) { + var kind = ts.stringToToken(text); + return kind === undefined + ? textPart(text) + : keywordPart(kind); + } + ts.textOrKeywordPart = textOrKeywordPart; function textPart(text) { - return displayPart(text, 17); + return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; function lineBreakPart() { - return displayPart("\n", 6); + return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } ts.lineBreakPart = lineBreakPart; function mapToDisplayParts(writeDisplayParts) { @@ -24719,6 +26347,8 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { var formatting; @@ -24763,21 +26393,21 @@ var ts; var t; var pos = scanner.getStartPos(); while (pos < endPos) { - var _t = scanner.getToken(); - if (!ts.isTrivia(_t)) { + var t_2 = scanner.getToken(); + if (!ts.isTrivia(t_2)) { break; } scanner.scan(); - var _item = { + var item_4 = { pos: pos, end: scanner.getStartPos(), - kind: _t + kind: t_2 }; pos = scanner.getStartPos(); if (!leadingTrivia) { leadingTrivia = []; } - leadingTrivia.push(_item); + leadingTrivia.push(item_4); } savedPos = scanner.getStartPos(); } @@ -24785,8 +26415,8 @@ var ts; if (node) { switch (node.kind) { case 27: - case 59: case 60: + case 61: case 42: case 41: return true; @@ -24802,7 +26432,7 @@ var ts; container.kind === 13; } function startsWithSlashToken(t) { - return t === 36 || t === 56; + return t === 36 || t === 57; } function readTokenInfo(n) { if (!isOnToken()) { @@ -24881,8 +26511,8 @@ var ts; } function isOnToken() { var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var _startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); - return _startPos < endPos && current !== 1 && !ts.isTrivia(current); + var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + return startPos < endPos && current !== 1 && !ts.isTrivia(current); } function fixTokenKind(tokenInfo, container) { if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { @@ -24894,6 +26524,21 @@ var ts; formatting.getFormattingScanner = getFormattingScanner; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -24972,7 +26617,36 @@ var ts; formatting.FormattingContext = FormattingContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// /// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -24994,6 +26668,35 @@ var ts; formatting.Rule = Rule; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// /// var ts; (function (ts) { @@ -25025,6 +26728,35 @@ var ts; formatting.RuleDescriptor = RuleDescriptor; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// /// var ts; (function (ts) { @@ -25053,6 +26785,21 @@ var ts; formatting.RuleOperation = RuleOperation; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25086,12 +26833,30 @@ var ts; formatting.RuleOperationContext = RuleOperationContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; (function (formatting) { var Rules = (function () { function Rules() { + /// + /// Common Rules + /// this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -25102,8 +26867,8 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(50, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 75), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 99), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 76), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 100), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.FromTokens([17, 19, 23, 22])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -25113,9 +26878,9 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([64, 3]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([65, 3]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 74, 95, 80, 75]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 75, 96, 81, 76]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); @@ -25134,25 +26899,25 @@ var ts; this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(34, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([97, 93, 87, 73, 89, 96]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104, 69]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98, 94, 88, 74, 90, 97]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105, 70]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(82, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(98, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(89, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 74, 75, 66]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([95, 80]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([115, 119]), 64), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(99, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 75, 76, 67]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96, 81]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 120]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(113, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 117]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([68, 114, 76, 77, 78, 115, 102, 84, 103, 116, 106, 108, 119, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([78, 102])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117, 118]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 103, 85, 104, 117, 107, 109, 120, 110]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 103])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 64), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(50, formatting.Shared.TokenRange.FromTokens([17, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); @@ -25225,42 +26990,42 @@ var ts; this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(82, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(82, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var _name in o) { - if (o[_name] === rule) { - return _name; + for (var name_19 in o) { + if (o[name_19] === rule) { + return name_19; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 183; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 167: - case 168: + case 169: + case 170: return true; - case 203: - case 193: - case 128: - case 220: - case 130: + case 205: + case 195: case 129: - return context.currentTokenSpan.kind === 52 || context.nextTokenSpan.kind === 52; - case 182: - return context.currentTokenSpan.kind === 85 || context.nextTokenSpan.kind === 85; - case 183: - return context.currentTokenSpan.kind === 124 || context.nextTokenSpan.kind === 124; - case 150: - return context.currentTokenSpan.kind === 52 || context.nextTokenSpan.kind === 52; + case 223: + case 132: + case 131: + return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; + case 184: + return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; + case 185: + return context.currentTokenSpan.kind === 125 || context.nextTokenSpan.kind === 125; + case 152: + return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; } return false; }; @@ -25268,9 +27033,25 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 168; + return context.contextNode.kind === 170; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { + //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. + //// + //// Ex: + //// if (1) { .... + //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context + //// + //// Ex: + //// if (1) + //// { ... } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. + //// + //// Ex: + //// if (1) + //// { ... + //// } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { @@ -25293,26 +27074,26 @@ var ts; return true; } switch (node.kind) { - case 174: - case 202: - case 152: - case 201: + case 176: + case 204: + case 154: + case 203: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 195: - case 132: - case 131: - case 134: - case 135: - case 136: - case 160: - case 133: - case 161: case 197: + case 134: + case 133: + case 136: + case 137: + case 138: + case 162: + case 135: + case 163: + case 199: return true; } return false; @@ -25322,53 +27103,53 @@ var ts; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 196: - case 197: + case 198: case 199: - case 143: - case 200: + case 201: + case 145: + case 202: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 196: - case 200: - case 199: - case 174: - case 217: + case 198: + case 202: case 201: - case 188: + case 176: + case 220: + case 203: + case 190: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 178: - case 188: - case 181: - case 182: - case 183: case 180: - case 191: - case 179: - case 187: - case 217: + case 190: + case 183: + case 184: + case 185: + case 182: + case 193: + case 181: + case 189: + case 220: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 152; + return context.contextNode.kind === 154; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 155; + return context.contextNode.kind === 157; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 156; + return context.contextNode.kind === 158; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -25380,35 +27161,35 @@ var ts; return context.TokensAreOnSameLine(); }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 194 && + return context.currentTokenParent.kind === 196 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind != 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 200; + return context.contextNode.kind === 202; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 143; + return context.contextNode.kind === 145; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 && token.kind !== 25) { return false; } switch (parent.kind) { - case 139: - case 196: + case 141: + case 198: + case 199: case 197: - case 195: - case 160: - case 161: - case 132: - case 131: - case 136: - case 137: - case 155: - case 156: + case 162: + case 163: + case 134: + case 133: + case 138: + case 139: + case 157: + case 158: return true; default: return false; @@ -25419,13 +27200,28 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 98 && context.currentTokenParent.kind === 164; + return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 166; }; return Rules; })(); formatting.Rules = Rules; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25441,7 +27237,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 124 + 1; + this.mapRowLength = 125 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -25536,7 +27332,7 @@ var ts; var position; if (rule.Operation.Action == 1) { position = specificTokens ? - 0 : + RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; } else if (!rule.Operation.Context.IsAny()) { @@ -25562,6 +27358,21 @@ var ts; formatting.RulesBucket = RulesBucket; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25617,7 +27428,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 124; token++) { + for (var token = 0; token <= 125; token++) { result.push(token); } return result; @@ -25659,23 +27470,64 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(65, 124); - TokenRange.BinaryOperators = TokenRange.FromRange(24, 63); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([85, 86, 124]); + TokenRange.Keywords = TokenRange.FromRange(66, 125); + TokenRange.BinaryOperators = TokenRange.FromRange(24, 64); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38, 39, 47, 46]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 64, 16, 18, 14, 92, 87]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([64, 16, 92, 87]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([64, 17, 19, 87]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([64, 16, 92, 87]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([64, 17, 19, 87]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 65, 16, 18, 14, 93, 88]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([64, 118, 120, 112, 121, 98, 111]); + TokenRange.TypeNames = TokenRange.FromTokens([65, 119, 121, 113, 122, 99, 112]); return TokenRange; })(); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25761,6 +27613,10 @@ var ts; formatting.RulesProvider = RulesProvider; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// +/// +/// +/// var ts; (function (ts) { var formatting; @@ -25802,13 +27658,13 @@ var ts; } formatting.formatSelection = formatSelection; function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { - var _parent = findOutermostParent(position, expectedLastToken, sourceFile); - if (!_parent) { + var parent = findOutermostParent(position, expectedLastToken, sourceFile); + if (!parent) { return []; } var span = { - pos: ts.getLineStartPositionForPosition(_parent.getStart(sourceFile), sourceFile), - end: _parent.end + pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), + end: parent.end }; return formatSpan(span, sourceFile, options, rulesProvider, requestKind); } @@ -25830,17 +27686,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 196: - case 197: + case 198: + case 199: return ts.rangeContainsRange(parent.members, node); - case 200: + case 202: var body = parent.body; - return body && body.kind === 174 && ts.rangeContainsRange(body.statements, node); - case 221: - case 174: - case 201: + return body && body.kind === 176 && ts.rangeContainsRange(body.statements, node); + case 224: + case 176: + case 203: return ts.rangeContainsRange(parent.statements, node); - case 217: + case 220: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -25945,10 +27801,10 @@ var ts; } } else { - var _startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; + var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); - if (_startLine !== parentStartLine || startPos === column) { + if (startLine !== parentStartLine || startPos === column) { return column; } } @@ -25959,9 +27815,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 221 || - parent.kind === 214 || - parent.kind === 215) { + parent.kind === 224 || + parent.kind === 217 || + parent.kind === 218) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -25987,6 +27843,26 @@ var ts; delta: delta }; } + function getFirstNonDecoratorTokenOfNode(node) { + if (node.modifiers && node.modifiers.length) { + return node.modifiers[0].kind; + } + switch (node.kind) { + case 198: return 69; + case 199: return 104; + case 197: return 83; + case 201: return 201; + case 136: return 116; + case 137: return 120; + case 134: + if (node.asteriskToken) { + return 35; + } + case 132: + case 129: + return node.name.kind; + } + } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { return { getIndentationForComment: function (kind) { @@ -25998,13 +27874,19 @@ var ts; return indentation; }, getIndentationForToken: function (line, kind) { + if (nodeStartLine !== line && node.decorators) { + if (kind === getFirstNonDecoratorTokenOfNode(node)) { + return indentation; + } + } switch (kind) { case 14: case 15: case 18: case 19: - case 75: - case 99: + case 76: + case 100: + case 52: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -26065,19 +27947,19 @@ var ts; return inheritedIndentation; } while (formattingScanner.isOnToken()) { - var _tokenInfo = formattingScanner.readTokenInfo(node); - if (_tokenInfo.token.end > childStartPos) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(_tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; } if (ts.isToken(child)) { - var _tokenInfo_1 = formattingScanner.readTokenInfo(child); - ts.Debug.assert(_tokenInfo_1.token.end === child.end); - consumeTokenAndAdvanceScanner(_tokenInfo_1, node, parentDynamicIndentation); + var tokenInfo = formattingScanner.readTokenInfo(child); + ts.Debug.assert(tokenInfo.token.end === child.end); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } var childIndentation = computeIndentation(child, childStart.line, childIndentationAmount, node, parentDynamicIndentation, parentStartLine); @@ -26089,34 +27971,34 @@ var ts; var listStartToken = getOpenTokenForList(parent, nodes); var listEndToken = getCloseTokenForOpenToken(listStartToken); var listDynamicIndentation = parentDynamicIndentation; - var _startLine = parentStartLine; + var startLine = parentStartLine; if (listStartToken !== 0) { while (formattingScanner.isOnToken()) { - var _tokenInfo = formattingScanner.readTokenInfo(parent); - if (_tokenInfo.token.end > nodes.pos) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.end > nodes.pos) { break; } - else if (_tokenInfo.token.kind === listStartToken) { - _startLine = sourceFile.getLineAndCharacterOfPosition(_tokenInfo.token.pos).line; - var _indentation = computeIndentation(_tokenInfo.token, _startLine, -1, parent, parentDynamicIndentation, _startLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, _indentation.indentation, _indentation.delta); - consumeTokenAndAdvanceScanner(_tokenInfo, parent, listDynamicIndentation); + else if (tokenInfo.token.kind === listStartToken) { + startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, startLine); + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } else { - consumeTokenAndAdvanceScanner(_tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); } } } var inheritedIndentation = -1; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, _startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, true); } if (listEndToken !== 0) { if (formattingScanner.isOnToken()) { - var _tokenInfo_1 = formattingScanner.readTokenInfo(parent); - if (_tokenInfo_1.token.kind === listEndToken && ts.rangeContainsRange(parent, _tokenInfo_1.token)) { - consumeTokenAndAdvanceScanner(_tokenInfo_1, parent, listDynamicIndentation); + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } } } @@ -26167,8 +28049,8 @@ var ts; break; case 2: if (indentNextTokenOrTrivia) { - var _commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, _commentIndentation, false); + var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); + insertIndentation(triviaItem.pos, commentIndentation_1, false); indentNextTokenOrTrivia = false; } break; @@ -26260,10 +28142,10 @@ var ts; } } function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { - var _startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; + var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; var parts; - if (_startLine === endLine) { + if (startLine === endLine) { if (!firstLineIsIndented) { insertIndentation(commentRange.pos, indentation, false); } @@ -26272,14 +28154,14 @@ var ts; else { parts = []; var startPos = commentRange.pos; - for (var line = _startLine; line < endLine; ++line) { + for (var line = startLine; line < endLine; ++line) { var endOfLine = ts.getEndLinePosition(line, sourceFile); parts.push({ pos: startPos, end: endOfLine }); startPos = ts.getStartPositionOfLine(line + 1, sourceFile); } parts.push({ pos: startPos, end: commentRange.end }); } - var startLinePos = ts.getStartPositionOfLine(_startLine, sourceFile); + var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); if (indentation === nonWhitespaceColumnInFirstPart.column) { return; @@ -26287,21 +28169,21 @@ var ts; var startIndex = 0; if (firstLineIsIndented) { startIndex = 1; - _startLine++; + startLine++; } - var _delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; ++i, ++_startLine) { - var _startLinePos = ts.getStartPositionOfLine(_startLine, sourceFile); + var delta = indentation - nonWhitespaceColumnInFirstPart.column; + for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { + var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - var newIndentation = nonWhitespaceCharacterAndColumn.column + _delta; + var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; if (newIndentation > 0) { var indentationString = getIndentationString(newIndentation, options); - recordReplace(_startLinePos, nonWhitespaceCharacterAndColumn.character, indentationString); + recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); } else { - recordDelete(_startLinePos, nonWhitespaceCharacterAndColumn.character); + recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); } } } @@ -26368,20 +28250,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 174: - case 201: + case 176: + case 203: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 135: + case 197: + case 162: + case 134: case 133: - case 195: - case 160: - case 132: - case 131: - case 161: + case 163: if (node.typeParameters === list) { return 24; } @@ -26389,8 +28271,8 @@ var ts; return 16; } break; - case 155: - case 156: + case 157: + case 158: if (node.typeArguments === list) { return 24; } @@ -26398,7 +28280,7 @@ var ts; return 16; } break; - case 139: + case 141: if (node.typeArguments === list) { return 24; } @@ -26414,9 +28296,15 @@ var ts; } return 0; } + var internedSizes; var internedTabsIndentation; var internedSpacesIndentation; function getIndentationString(indentation, options) { + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + if (resetInternedStrings) { + internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; + } if (!options.ConvertTabsToSpaces) { var tabs = Math.floor(indentation / options.TabSize); var spaces = indentation - tabs * options.TabSize; @@ -26459,6 +28347,7 @@ var ts; formatting.getIndentationString = getIndentationString; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { var formatting; @@ -26483,7 +28372,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 167) { + if (precedingToken.kind === 23 && precedingToken.parent.kind !== 169) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -26494,7 +28383,7 @@ var ts; var currentStart; var indentationDelta; while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0)) { + if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { indentationDelta = 0; @@ -26504,9 +28393,9 @@ var ts; } break; } - var _actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (_actualIndentation !== -1) { - return _actualIndentation; + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; } previous = current; current = current.parent; @@ -26523,9 +28412,9 @@ var ts; } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var _parent = current.parent; + var parent = current.parent; var parentStart; - while (_parent) { + while (parent) { var useActualIndentation = true; if (ignoreActualIndentationRange) { var start = current.getStart(sourceFile); @@ -26537,21 +28426,21 @@ var ts; return actualIndentation + indentationDelta; } } - parentStart = getParentStart(_parent, current, sourceFile); + parentStart = getParentStart(parent, current, sourceFile); var parentAndChildShareLine = parentStart.line === currentStart.line || - childStartsOnTheSameLineWithElseInIfStatement(_parent, current, currentStart.line, sourceFile); + childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { - var _actualIndentation = getActualIndentationForNode(current, _parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (_actualIndentation !== -1) { - return _actualIndentation + indentationDelta; + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; } } - if (shouldIndentChildNode(_parent.kind, current.kind) && !parentAndChildShareLine) { + if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { indentationDelta += options.IndentSize; } - current = _parent; + current = parent; currentStart = parentStart; - _parent = current.parent; + parent = current.parent; } return indentationDelta; } @@ -26573,7 +28462,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 221 || !parentAndChildShareLine); + (parent.kind === 224 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -26596,12 +28485,9 @@ var ts; function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 178 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 75, sourceFile); + if (parent.kind === 180 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 76, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -26612,23 +28498,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 139: + case 141: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 152: + case 154: return node.parent.properties; - case 151: + case 153: return node.parent.elements; - case 195: - case 160: - case 161: - case 132: - case 131: - case 136: - case 137: { + case 197: + case 162: + case 163: + case 134: + case 133: + case 138: + case 139: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -26639,15 +28525,15 @@ var ts; } break; } - case 156: - case 155: { - var _start = node.getStart(sourceFile); + case 158: + case 157: { + var start = node.getStart(sourceFile); if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, _start, node.getEnd())) { + ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { return node.parent.typeArguments; } if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, _start, node.getEnd())) { + ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { return node.parent.arguments; } break; @@ -26709,25 +28595,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 196: - case 197: + case 198: case 199: - case 151: - case 174: case 201: - case 152: - case 143: - case 202: - case 215: - case 214: - case 159: - case 155: - case 156: - case 175: - case 193: - case 209: - case 186: - case 168: + case 153: + case 176: + case 203: + case 154: + case 145: + case 147: + case 204: + case 218: + case 217: + case 161: + case 157: + case 158: + case 177: + case 195: + case 211: + case 188: + case 170: + case 151: + case 150: return true; } return false; @@ -26737,106 +28626,46 @@ var ts; return true; } switch (parent) { - case 179: - case 180: - case 182: - case 183: case 181: - case 178: - case 195: - case 160: - case 132: - case 131: - case 161: - case 133: + case 182: + case 184: + case 185: + case 183: + case 180: + case 197: + case 162: case 134: + case 133: + case 138: + case 163: case 135: - return child !== 174; + case 136: + case 137: + return child !== 176; default: return false; } } SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = children[children.length - 1]; - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === 22 && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - function isCompletedNode(n, sourceFile) { - if (n.getFullWidth() === 0) { - return false; - } - switch (n.kind) { - case 196: - case 197: - case 199: - case 152: - case 174: - case 201: - case 202: - return nodeEndsWith(n, 15, sourceFile); - case 217: - return isCompletedNode(n.block, sourceFile); - case 159: - case 136: - case 155: - case 137: - return nodeEndsWith(n, 17, sourceFile); - case 195: - case 160: - case 132: - case 131: - case 161: - return !n.body || isCompletedNode(n.body, sourceFile); - case 200: - return n.body && isCompletedNode(n.body, sourceFile); - case 178: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); - } - return isCompletedNode(n.thenStatement, sourceFile); - case 177: - return isCompletedNode(n.expression, sourceFile); - case 151: - return nodeEndsWith(n, 19, sourceFile); - case 214: - case 215: - return false; - case 181: - return isCompletedNode(n.statement, sourceFile); - case 182: - return isCompletedNode(n.statement, sourceFile); - case 183: - return isCompletedNode(n.statement, sourceFile); - case 180: - return isCompletedNode(n.statement, sourceFile); - case 179: - var hasWhileKeyword = ts.findChildOfKind(n, 99, sourceFile); - if (hasWhileKeyword) { - return nodeEndsWith(n, 17, sourceFile); - } - return isCompletedNode(n.statement, sourceFile); - default: - return true; - } - } })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// var __extends = this.__extends || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }; +/// +/// +/// +/// +/// +/// +/// +/// +/// var ts; (function (ts) { ts.servicesVersion = "0.4"; @@ -26914,7 +28743,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(222, nodes.pos, nodes.end, 1024, this); + var list = createNode(225, nodes.pos, nodes.end, 1024, this); list._children = []; var pos = nodes.pos; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { @@ -26933,7 +28762,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 125) { + if (this.kind >= 126) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -26978,7 +28807,7 @@ var ts; var children = this.getChildren(); for (var _i = 0, _n = children.length; _i < _n; _i++) { var child = children[_i]; - if (child.kind < 125) { + if (child.kind < 126) { return child; } return child.getFirstToken(sourceFile); @@ -26988,7 +28817,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 125) { + if (child.kind < 126) { return child; } return child.getLastToken(sourceFile); @@ -27034,7 +28863,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 128) { + if (canUseParsedParamTagComments && declaration.kind === 129) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -27042,13 +28871,13 @@ var ts; } }); } - if (declaration.kind === 200 && declaration.body.kind === 200) { + if (declaration.kind === 202 && declaration.body.kind === 202) { return; } - while (declaration.kind === 200 && declaration.parent.kind === 200) { + while (declaration.kind === 202 && declaration.parent.kind === 202) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 193 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 195 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -27093,13 +28922,14 @@ var ts; return isName(pos, end, sourceFile, paramTag); } function pushDocCommentLineText(docComments, text, blankLineCount) { - while (blankLineCount--) + while (blankLineCount--) { docComments.push(ts.textPart("")); + } docComments.push(ts.textPart(text)); } function getCleanedJsDocComment(pos, end, sourceFile) { var spacesToRemoveAfterAsterisk; - var _docComments = []; + var docComments = []; var blankLineCount = 0; var isInParamTag = false; while (pos < end) { @@ -27134,14 +28964,14 @@ var ts; } pos = consumeLineBreaks(pos, end, sourceFile); if (docCommentTextOfLine) { - pushDocCommentLineText(_docComments, docCommentTextOfLine, blankLineCount); + pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); blankLineCount = 0; } - else if (!isInParamTag && _docComments.length) { + else if (!isInParamTag && docComments.length) { blankLineCount++; } } - return _docComments; + return docComments; } function getCleanedParamJsDocComment(pos, end, sourceFile) { var paramHelpStringMargin; @@ -27242,8 +29072,8 @@ var ts; } var consumedSpaces = pos - startOfLinePos; if (consumedSpaces < paramHelpStringMargin) { - var _ch = sourceFile.text.charCodeAt(pos); - if (_ch === 42) { + var ch = sourceFile.text.charCodeAt(pos); + if (ch === 42) { pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); } } @@ -27332,9 +29162,9 @@ var ts; var namedDeclarations = []; ts.forEachChild(sourceFile, function visit(node) { switch (node.kind) { - case 195: - case 132: - case 131: + case 197: + case 134: + case 133: var functionDeclaration = node; if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) { var lastDeclaration = namedDeclarations.length > 0 ? @@ -27351,64 +29181,64 @@ var ts; ts.forEachChild(node, visit); } break; - case 196: - case 197: case 198: case 199: case 200: - case 203: - case 212: - case 208: - case 203: + case 201: + case 202: case 205: - case 206: - case 134: - case 135: - case 143: + case 214: + case 210: + case 205: + case 207: + case 208: + case 136: + case 137: + case 145: if (node.name) { namedDeclarations.push(node); } - case 133: - case 175: - case 194: - case 148: - case 149: - case 201: + case 135: + case 177: + case 196: + case 150: + case 151: + case 203: ts.forEachChild(node, visit); break; - case 174: + case 176: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 128: + case 129: if (!(node.flags & 112)) { break; } - case 193: - case 150: + case 195: + case 152: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 220: - case 130: - case 129: + case 223: + case 132: + case 131: namedDeclarations.push(node); break; - case 210: + case 212: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 204: + case 206: var importClause = node.importClause; if (importClause) { if (importClause.name) { namedDeclarations.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { namedDeclarations.push(importClause.namedBindings); } else { @@ -27547,14 +29377,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 160) { + if (declaration.kind === 162) { return true; } - if (declaration.kind !== 193 && declaration.kind !== 195) { + if (declaration.kind !== 195 && declaration.kind !== 197) { return false; } - for (var _parent = declaration.parent; !ts.isFunctionBlock(_parent); _parent = _parent.parent) { - if (_parent.kind === 221 || _parent.kind === 201) { + for (var parent_7 = declaration.parent; !ts.isFunctionBlock(parent_7); parent_7 = parent_7.parent) { + if (parent_7.kind === 224 || parent_7.kind === 203) { return false; } } @@ -27656,17 +29486,17 @@ var ts; if (!scriptSnapshot) { throw new Error("Could not find file: '" + fileName + "'."); } - var _version = this.host.getScriptVersion(fileName); + var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, _version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true); } - else if (this.currentFileVersion !== _version) { + else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); - sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, _version, editRange); + sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); } if (sourceFile) { - this.currentFileVersion = _version; + this.currentFileVersion = version; this.currentFileName = fileName; this.currentFileScriptSnapshot = scriptSnapshot; this.currentSourceFile = sourceFile; @@ -27812,25 +29642,25 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1) { - if (token === 84) { + if (token === 85) { token = scanner.scan(); if (token === 8) { recordModuleName(); continue; } else { - if (token === 64) { + if (token === 65) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); continue; } } - else if (token === 52) { + else if (token === 53) { token = scanner.scan(); - if (token === 117) { + if (token === 118) { token = scanner.scan(); if (token === 16) { token = scanner.scan(); @@ -27855,7 +29685,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -27865,11 +29695,11 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 101) { + if (token === 102) { token = scanner.scan(); - if (token === 64) { + if (token === 65) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -27880,7 +29710,7 @@ var ts; } } } - else if (token === 77) { + else if (token === 78) { token = scanner.scan(); if (token === 14) { token = scanner.scan(); @@ -27889,7 +29719,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -27899,7 +29729,7 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -27920,7 +29750,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 189 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 191 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -27928,17 +29758,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 64 && - (node.parent.kind === 185 || node.parent.kind === 184) && + return node.kind === 65 && + (node.parent.kind === 187 || node.parent.kind === 186) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 64 && - node.parent.kind === 189 && + return node.kind === 65 && + node.parent.kind === 191 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 189; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 191; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -27949,48 +29779,48 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 125 && node.parent.right === node; + return node.parent.kind === 126 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 153 && node.parent.name === node; + return node && node.parent && node.parent.kind === 155 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 155 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 157 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 156 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 158 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 200 && node.parent.name === node; + return node.parent.kind === 202 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 64 && + return node.kind === 65 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 64 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 218 || node.parent.kind === 219) && node.parent.name === node; + return (node.kind === 65 || node.kind === 8 || node.kind === 7) && + (node.parent.kind === 221 || node.parent.kind === 222) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 || node.kind === 7) { switch (node.parent.kind) { - case 130: - case 129: - case 218: - case 220: case 132: case 131: + case 221: + case 223: case 134: - case 135: - case 200: + case 133: + case 136: + case 137: + case 202: return node.parent.name === node; - case 154: + case 156: return node.parent.argumentExpression === node; } } @@ -28028,7 +29858,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 65; i <= 124; i++) { + for (var i = 66; i <= 125; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -28042,17 +29872,17 @@ var ts; return undefined; } switch (node.kind) { - case 221: - case 132: - case 131: - case 195: - case 160: + case 224: case 134: - case 135: - case 196: + case 133: case 197: + case 162: + case 136: + case 137: + case 198: case 199: - case 200: + case 201: + case 202: return node; } } @@ -28060,38 +29890,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 200: return ScriptElementKind.moduleElement; - case 196: return ScriptElementKind.classElement; - case 197: return ScriptElementKind.interfaceElement; - case 198: return ScriptElementKind.typeElement; - case 199: return ScriptElementKind.enumElement; - case 193: + case 202: return ScriptElementKind.moduleElement; + case 198: return ScriptElementKind.classElement; + case 199: return ScriptElementKind.interfaceElement; + case 200: return ScriptElementKind.typeElement; + case 201: return ScriptElementKind.enumElement; + case 195: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 195: return ScriptElementKind.functionElement; - case 134: return ScriptElementKind.memberGetAccessorElement; - case 135: return ScriptElementKind.memberSetAccessorElement; + case 197: return ScriptElementKind.functionElement; + case 136: return ScriptElementKind.memberGetAccessorElement; + case 137: return ScriptElementKind.memberSetAccessorElement; + case 134: + case 133: + return ScriptElementKind.memberFunctionElement; case 132: case 131: - return ScriptElementKind.memberFunctionElement; - case 130: - case 129: return ScriptElementKind.memberVariableElement; - case 138: return ScriptElementKind.indexSignatureElement; - case 137: return ScriptElementKind.constructSignatureElement; - case 136: return ScriptElementKind.callSignatureElement; - case 133: return ScriptElementKind.constructorImplementationElement; - case 127: return ScriptElementKind.typeParameterElement; - case 220: return ScriptElementKind.variableElement; - case 128: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 203: - case 208: + case 140: return ScriptElementKind.indexSignatureElement; + case 139: return ScriptElementKind.constructSignatureElement; + case 138: return ScriptElementKind.callSignatureElement; + case 135: return ScriptElementKind.constructorImplementationElement; + case 128: return ScriptElementKind.typeParameterElement; + case 223: return ScriptElementKind.variableElement; + case 129: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 205: - case 212: - case 206: + case 210: + case 207: + case 214: + case 208: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -28105,7 +29935,6 @@ var ts; var typeInfoResolver; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - var activeCompletionSession; if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } @@ -28169,8 +29998,8 @@ var ts; return undefined; } if (!changesInCompilationSettingsAffectSyntax) { - var _oldSourceFile = program && program.getSourceFile(fileName); - if (_oldSourceFile) { + var oldSourceFile = program && program.getSourceFile(fileName); + if (oldSourceFile) { return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } } @@ -28187,9 +30016,9 @@ var ts; if (program.getSourceFiles().length !== rootFileNames.length) { return false; } - for (var _a = 0, _b = rootFileNames.length; _a < _b; _a++) { - var _fileName = rootFileNames[_a]; - if (!sourceFileUpToDate(program.getSourceFile(_fileName))) { + for (var _i = 0, _n = rootFileNames.length; _i < _n; _i++) { + var fileName = rootFileNames[_i]; + if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } } @@ -28224,35 +30053,42 @@ var ts; return semanticDiagnostics; } var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); - return semanticDiagnostics.concat(declarationDiagnostics); + return ts.concatenate(semanticDiagnostics, declarationDiagnostics); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); return program.getGlobalDiagnostics(); } - function getValidCompletionEntryDisplayName(symbol, target) { + function getCompletionEntryDisplayName(symbol, target, performCharacterChecks) { var displayName = symbol.getName(); - if (displayName && displayName.length > 0) { - var firstCharCode = displayName.charCodeAt(0); - if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { + if (!displayName) { + return undefined; + } + var firstCharCode = displayName.charCodeAt(0); + if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { + return undefined; + } + if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && + (firstCharCode === 39 || firstCharCode === 34)) { + displayName = displayName.substring(1, displayName.length - 1); + } + if (!displayName) { + return undefined; + } + if (performCharacterChecks) { + if (!ts.isIdentifierStart(displayName.charCodeAt(0), target)) { return undefined; } - if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && - (firstCharCode === 39 || firstCharCode === 34)) { - displayName = displayName.substring(1, displayName.length - 1); - } - var isValid = ts.isIdentifierStart(displayName.charCodeAt(0), target); - for (var _i = 1, n = displayName.length; isValid && _i < n; _i++) { - isValid = ts.isIdentifierPart(displayName.charCodeAt(_i), target); - } - if (isValid) { - return ts.unescapeIdentifier(displayName); + for (var i = 1, n = displayName.length; i < n; i++) { + if (!ts.isIdentifierPart(displayName.charCodeAt(i), target)) { + return undefined; + } } } - return undefined; + return ts.unescapeIdentifier(displayName); } function createCompletionEntry(symbol, typeChecker, location) { - var displayName = getValidCompletionEntryDisplayName(symbol, program.getCompilerOptions().target); + var displayName = getCompletionEntryDisplayName(symbol, program.getCompilerOptions().target, true); if (!displayName) { return undefined; } @@ -28262,63 +30098,53 @@ var ts; kindModifiers: getSymbolModifiers(symbol) }; } - function getCompletionsAtPosition(fileName, position) { - synchronizeHostData(); + function getCompletionData(fileName, position) { var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); - log("getCompletionsAtPosition: Get current token: " + (new Date().getTime() - start)); + log("getCompletionData: Get current token: " + (new Date().getTime() - start)); start = new Date().getTime(); var insideComment = isInsideComment(sourceFile, currentToken, position); - log("getCompletionsAtPosition: Is inside comment: " + (new Date().getTime() - start)); + log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { log("Returning an empty list because completion was inside a comment."); return undefined; } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); - log("getCompletionsAtPosition: Get previous token 1: " + (new Date().getTime() - start)); - if (previousToken && position <= previousToken.end && previousToken.kind === 64) { - var _start = new Date().getTime(); - previousToken = ts.findPrecedingToken(previousToken.pos, sourceFile); - log("getCompletionsAtPosition: Get previous token 2: " + (new Date().getTime() - _start)); + log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); + var contextToken = previousToken; + if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { + var start_1 = new Date().getTime(); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_1)); } - if (previousToken && isCompletionListBlocker(previousToken)) { + if (contextToken && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var node; - var isRightOfDot; - if (previousToken && previousToken.kind === 20 && previousToken.parent.kind === 153) { - node = previousToken.parent.expression; + var node = currentToken; + var isRightOfDot = false; + if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 155) { + node = contextToken.parent.expression; isRightOfDot = true; } - else if (previousToken && previousToken.kind === 20 && previousToken.parent.kind === 125) { - node = previousToken.parent.left; + else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 126) { + node = contextToken.parent.left; isRightOfDot = true; } - else { - node = currentToken; - isRightOfDot = false; - } - activeCompletionSession = { - fileName: fileName, - position: position, - entries: [], - symbols: {}, - typeChecker: typeInfoResolver - }; - log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart)); - var _location = ts.getTouchingPropertyName(sourceFile, position); + var location = ts.getTouchingPropertyName(sourceFile, position); + var target = program.getCompilerOptions().target; var semanticStart = new Date().getTime(); var isMemberCompletion; var isNewIdentifierLocation; + var symbols; if (isRightOfDot) { - var symbols = []; + symbols = []; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 64 || node.kind === 125 || node.kind === 153) { + if (node.kind === 65 || node.kind === 126 || node.kind === 155) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeInfoResolver.getAliasedSymbol(symbol); @@ -28339,10 +30165,9 @@ var ts; } }); } - getCompletionEntriesFromSymbols(symbols, activeCompletionSession); } else { - var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(previousToken); + var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); if (containingObjectLiteral) { isMemberCompletion = true; isNewIdentifierLocation = true; @@ -28352,65 +30177,54 @@ var ts; } var contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType); if (contextualTypeMembers && contextualTypeMembers.length > 0) { - var filteredMembers = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); - getCompletionEntriesFromSymbols(filteredMembers, activeCompletionSession); + symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(previousToken, 205)) { + else if (ts.getAncestor(contextToken, 207)) { isMemberCompletion = true; isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(previousToken)) { - var importDeclaration = ts.getAncestor(previousToken, 204); + if (showCompletionsInImportsClause(contextToken)) { + var importDeclaration = ts.getAncestor(contextToken, 206); ts.Debug.assert(importDeclaration !== undefined); - var _exports = typeInfoResolver.getExportsOfExternalModule(importDeclaration); - var filteredExports = filterModuleExports(_exports, importDeclaration); - getCompletionEntriesFromSymbols(filteredExports, activeCompletionSession); + var exports_2 = typeInfoResolver.getExportsOfExternalModule(importDeclaration); + symbols = filterModuleExports(exports_2, importDeclaration); } } else { isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(previousToken); + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile); var symbolMeanings = 793056 | 107455 | 1536 | 8388608; - var _symbols = typeInfoResolver.getSymbolsInScope(node, symbolMeanings); - getCompletionEntriesFromSymbols(_symbols, activeCompletionSession); + symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings); } } - if (!isMemberCompletion) { - Array.prototype.push.apply(activeCompletionSession.entries, keywordCompletions); - } - log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart)); - return { - isMemberCompletion: isMemberCompletion, - isNewIdentifierLocation: isNewIdentifierLocation, - isBuilder: isNewIdentifierDefinitionLocation, - entries: activeCompletionSession.entries - }; - function getCompletionEntriesFromSymbols(symbols, session) { - var _start_1 = new Date().getTime(); - ts.forEach(symbols, function (symbol) { - var entry = createCompletionEntry(symbol, session.typeChecker, _location); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(session.symbols, id)) { - session.entries.push(entry); - session.symbols[id] = symbol; - } - } - }); - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - _start_1)); + log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location }; + function getScopeNode(initialToken, position, sourceFile) { + var scope = initialToken; + while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { + scope = scope.parent; + } + return scope; } function isCompletionListBlocker(previousToken) { - var _start_1 = new Date().getTime(); + var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || isIdentifierDefinitionLocation(previousToken) || isRightOfIllegalDot(previousToken); - log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - _start_1)); + log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } function showCompletionsInImportsClause(node) { if (node) { if (node.kind === 14 || node.kind === 23) { - return node.parent.kind === 207; + return node.parent.kind === 209; } } return false; @@ -28420,35 +30234,35 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 155 - || containingNodeKind === 133 - || containingNodeKind === 156 - || containingNodeKind === 151 - || containingNodeKind === 167; + return containingNodeKind === 157 + || containingNodeKind === 135 + || containingNodeKind === 158 + || containingNodeKind === 153 + || containingNodeKind === 169; case 16: - return containingNodeKind === 155 - || containingNodeKind === 133 - || containingNodeKind === 156 - || containingNodeKind === 159; + return containingNodeKind === 157 + || containingNodeKind === 135 + || containingNodeKind === 158 + || containingNodeKind === 161; case 18: - return containingNodeKind === 151; - case 116: + return containingNodeKind === 153; + case 117: return true; case 20: - return containingNodeKind === 200; + return containingNodeKind === 202; case 14: - return containingNodeKind === 196; - case 52: - return containingNodeKind === 193 - || containingNodeKind === 167; + return containingNodeKind === 198; + case 53: + return containingNodeKind === 195 + || containingNodeKind === 169; case 11: - return containingNodeKind === 169; + return containingNodeKind === 171; case 12: - return containingNodeKind === 173; - case 108: - case 106: + return containingNodeKind === 175; + case 109: case 107: - return containingNodeKind === 130; + case 108: + return containingNodeKind === 132; } switch (previousToken.getText()) { case "public": @@ -28463,9 +30277,9 @@ var ts; if (previousToken.kind === 8 || previousToken.kind === 9 || ts.isTemplateLiteralKind(previousToken.kind)) { - var _start_1 = previousToken.getStart(); + var start_2 = previousToken.getStart(); var end = previousToken.getEnd(); - if (_start_1 < position && position < end) { + if (start_2 < position && position < end) { return true; } else if (position === end) { @@ -28475,13 +30289,14 @@ var ts; return false; } function getContainingObjectLiteralApplicableForCompletion(previousToken) { + // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var _parent = previousToken.parent; + var parent_8 = previousToken.parent; switch (previousToken.kind) { case 14: case 23: - if (_parent && _parent.kind === 152) { - return _parent; + if (parent_8 && parent_8.kind === 154) { + return parent_8; } break; } @@ -28490,16 +30305,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 160: - case 161: - case 195: - case 132: - case 131: + case 162: + case 163: + case 197: case 134: - case 135: + case 133: case 136: case 137: case 138: + case 139: + case 140: return true; } return false; @@ -28509,58 +30324,58 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 193 || - containingNodeKind === 194 || - containingNodeKind === 175 || - containingNodeKind === 199 || - isFunction(containingNodeKind) || + return containingNodeKind === 195 || containingNodeKind === 196 || - containingNodeKind === 195 || + containingNodeKind === 177 || + containingNodeKind === 201 || + isFunction(containingNodeKind) || + containingNodeKind === 198 || containingNodeKind === 197 || - containingNodeKind === 149 || - containingNodeKind === 148; + containingNodeKind === 199 || + containingNodeKind === 151 || + containingNodeKind === 150; case 20: - return containingNodeKind === 149; + return containingNodeKind === 151; case 18: - return containingNodeKind === 149; + return containingNodeKind === 151; case 16: - return containingNodeKind === 217 || + return containingNodeKind === 220 || isFunction(containingNodeKind); case 14: - return containingNodeKind === 199 || - containingNodeKind === 197 || - containingNodeKind === 143 || - containingNodeKind === 148; + return containingNodeKind === 201 || + containingNodeKind === 199 || + containingNodeKind === 145 || + containingNodeKind === 150; case 22: - return containingNodeKind === 129 && - (previousToken.parent.parent.kind === 197 || - previousToken.parent.parent.kind === 143); + return containingNodeKind === 131 && + (previousToken.parent.parent.kind === 199 || + previousToken.parent.parent.kind === 145); case 24: - return containingNodeKind === 196 || - containingNodeKind === 195 || + return containingNodeKind === 198 || containingNodeKind === 197 || + containingNodeKind === 199 || isFunction(containingNodeKind); - case 109: - return containingNodeKind === 130; - case 21: - return containingNodeKind === 128 || - containingNodeKind === 133 || - (previousToken.parent.parent.kind === 149); - case 108: - case 106: - case 107: - return containingNodeKind === 128; - case 68: - case 76: - case 103: - case 82: - case 97: - case 115: - case 119: - case 84: - case 104: - case 69: case 110: + return containingNodeKind === 132; + case 21: + return containingNodeKind === 129 || + containingNodeKind === 135 || + (previousToken.parent.parent.kind === 151); + case 109: + case 107: + case 108: + return containingNodeKind === 129; + case 69: + case 77: + case 104: + case 83: + case 98: + case 116: + case 120: + case 85: + case 105: + case 70: + case 111: return true; } switch (previousToken.getText()) { @@ -28591,10 +30406,10 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 207) { + importDeclaration.importClause.namedBindings.kind === 209) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { - var _name = el.propertyName || el.name; - exisingImports[_name.text] = true; + var name = el.propertyName || el.name; + exisingImports[name.text] = true; }); } if (ts.isEmpty(exisingImports)) { @@ -28608,7 +30423,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 218 && m.kind !== 219) { + if (m.kind !== 221 && m.kind !== 222) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -28616,44 +30431,78 @@ var ts; } existingMemberNames[m.name.text] = true; }); - var _filteredMembers = []; + var filteredMembers = []; ts.forEach(contextualMemberSymbols, function (s) { if (!existingMemberNames[s.name]) { - _filteredMembers.push(s); + filteredMembers.push(s); } }); - return _filteredMembers; + return filteredMembers; + } + } + function getCompletionsAtPosition(fileName, position) { + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location; + if (!symbols || symbols.length === 0) { + return undefined; + } + var entries = getCompletionEntriesFromSymbols(symbols); + if (!isMemberCompletion) { + ts.addRange(entries, keywordCompletions); + } + return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + function getCompletionEntriesFromSymbols(symbols) { + var start = new Date().getTime(); + var entries = []; + var nameToSymbol = {}; + for (var _i = 0, _n = symbols.length; _i < _n; _i++) { + var symbol = symbols[_i]; + var entry = createCompletionEntry(symbol, typeInfoResolver, location); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!ts.lookUp(nameToSymbol, id)) { + entries.push(entry); + nameToSymbol[id] = symbol; + } + } + } + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); + return entries; } } function getCompletionEntryDetails(fileName, position, entryName) { - var sourceFile = getValidSourceFile(fileName); - var session = activeCompletionSession; - if (!session || session.fileName !== fileName || session.position !== position) { - return undefined; + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (completionData) { + var symbols = completionData.symbols, location_2 = completionData.location; + var target = program.getCompilerOptions().target; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayName(s, target, false) === entryName ? s : undefined; }); + if (symbol) { + var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, typeInfoResolver, location_2, 7); + return { + name: entryName, + kind: displayPartsDocumentationsAndSymbolKind.symbolKind, + kindModifiers: getSymbolModifiers(symbol), + displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, + documentation: displayPartsDocumentationsAndSymbolKind.documentation + }; + } } - var symbol = ts.lookUp(activeCompletionSession.symbols, ts.escapeIdentifier(entryName)); - if (symbol) { - var _location = ts.getTouchingPropertyName(sourceFile, position); - var completionEntry = createCompletionEntry(symbol, session.typeChecker, _location); - ts.Debug.assert(session.typeChecker.getTypeOfSymbolAtLocation(symbol, _location) !== undefined, "Could not find type for symbol"); - var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), _location, session.typeChecker, _location, 7); - return { - name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, - kindModifiers: completionEntry.kindModifiers, - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation - }; - } - else { + var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); + if (keywordCompletion) { return { name: entryName, kind: ScriptElementKind.keyword, kindModifiers: ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, 5)], + displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], documentation: undefined }; } + return undefined; } function getSymbolKind(symbol, typeResolver, location) { var flags = symbol.getFlags(); @@ -28767,14 +30616,14 @@ var ts; var signature; type = typeResolver.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 153) { + if (location.parent && location.parent.kind === 155) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 155 || location.kind === 156) { + if (location.kind === 157 || location.kind === 158) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -28786,7 +30635,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 156 || callExpression.expression.kind === 90; + var useConstructSignatures = callExpression.kind === 158 || callExpression.expression.kind === 91; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -28798,12 +30647,10 @@ var ts; } else if (symbolFlags & 8388608) { symbolKind = ScriptElementKind.alias; - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart(symbolKind)); - displayParts.push(ts.punctuationPart(17)); + pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -28821,7 +30668,7 @@ var ts; displayParts.push(ts.punctuationPart(51)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } if (!(type.flags & 32768)) { @@ -28836,64 +30683,64 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 113 && location.parent.kind === 133)) { + (location.kind === 114 && location.parent.kind === 135)) { var functionDeclaration = location.parent; - var _allSignatures = functionDeclaration.kind === 133 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 135 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeResolver.isImplementationOfOverload(functionDeclaration)) { signature = typeResolver.getSignatureFromDeclaration(functionDeclaration); } else { - signature = _allSignatures[0]; + signature = allSignatures[0]; } - if (functionDeclaration.kind === 133) { + if (functionDeclaration.kind === 135) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 136 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 138 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } - addSignatureDisplayParts(signature, _allSignatures); + addSignatureDisplayParts(signature, allSignatures); hasAddedSymbolInfo = true; } } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - displayParts.push(ts.keywordPart(68)); + displayParts.push(ts.keywordPart(69)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(103)); + displayParts.push(ts.keywordPart(104)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(122)); + displayParts.push(ts.keywordPart(123)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(69)); + displayParts.push(ts.keywordPart(70)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(76)); + displayParts.push(ts.keywordPart(77)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(116)); + displayParts.push(ts.keywordPart(117)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -28905,60 +30752,60 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(85)); + displayParts.push(ts.keywordPart(86)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 127).parent; - var _signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 137) { - displayParts.push(ts.keywordPart(87)); + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128).parent; + var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 139) { + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 136 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 138 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, _signature, sourceFile, 32)); + displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, sourceFile, 32)); } } if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 220) { + if (declaration.kind === 223) { var constantValue = typeResolver.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), 7)); + displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } } } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(84)); + displayParts.push(ts.keywordPart(85)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 203) { + if (declaration.kind === 205) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(117)); + displayParts.push(ts.keywordPart(118)); displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), 8)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17)); } else { var internalAliasSymbol = typeResolver.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -28992,8 +30839,8 @@ var ts; symbolFlags & 131072 || symbolFlags & 98304 || symbolKind === ScriptElementKind.memberFunctionElement) { - var _allSignatures_1 = type.getCallSignatures(); - addSignatureDisplayParts(_allSignatures_1[0], _allSignatures_1); + var allSignatures = type.getCallSignatures(); + addSignatureDisplayParts(allSignatures[0], allSignatures); } } } @@ -29017,20 +30864,34 @@ var ts; function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); if (symbolKind) { - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart(symbolKind)); - displayParts.push(ts.punctuationPart(17)); + pushTypePart(symbolKind); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } } + function pushTypePart(symbolKind) { + switch (symbolKind) { + case ScriptElementKind.variableElement: + case ScriptElementKind.functionElement: + case ScriptElementKind.letElement: + case ScriptElementKind.constElement: + case ScriptElementKind.constructorImplementationElement: + displayParts.push(ts.textOrKeywordPart(symbolKind)); + return; + default: + displayParts.push(ts.punctuationPart(16)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(17)); + return; + } + } function addSignatureDisplayParts(signature, allSignatures, flags) { displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(16)); displayParts.push(ts.operatorPart(33)); - displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), 7)); + displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); displayParts.push(ts.punctuationPart(17)); @@ -29038,10 +30899,10 @@ var ts; documentation = signature.getDocumentationComment(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var _typeParameterParts = ts.mapToDisplayParts(function (writer) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, _typeParameterParts); + displayParts.push.apply(displayParts, typeParameterParts); } } function getQuickInfoAtPosition(fileName, position) { @@ -29054,11 +30915,11 @@ var ts; var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 64: - case 153: - case 125: - case 92: - case 90: + case 65: + case 155: + case 126: + case 93: + case 91: var type = typeInfoResolver.getTypeAtLocation(node); if (type) { return { @@ -29081,6 +30942,16 @@ var ts; documentation: displayPartsDocumentationsAndKind.documentation }; } + function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + kind: symbolKind, + name: symbolName, + containerKind: undefined, + containerName: containerName + }; + } function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -29091,7 +30962,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [getDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; } var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); if (comment) { @@ -29114,22 +30985,22 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 64 && node.parent === declaration) { + if (node.kind === 65 && node.parent === declaration) { symbol = typeInfoResolver.getAliasedSymbol(symbol); } } - var result = []; - if (node.parent.kind === 219) { + if (node.parent.kind === 222) { var shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); + if (!shorthandSymbol) { + return []; + } var shorthandDeclarations = shorthandSymbol.getDeclarations(); var shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node); var shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol); var shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node); - ts.forEach(shorthandDeclarations, function (declaration) { - result.push(getDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName)); - }); - return result; + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); } + var result = []; var declarations = symbol.getDeclarations(); var symbolName = typeInfoResolver.symbolToString(symbol); var symbolKind = getSymbolKind(symbol, typeInfoResolver, node); @@ -29138,46 +31009,15 @@ var ts; if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { ts.forEach(declarations, function (declaration) { - result.push(getDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); } return result; - function getDefinitionInfo(node, symbolKind, symbolName, containerName) { - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - kind: symbolKind, - name: symbolName, - containerKind: undefined, - containerName: containerName - }; - } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var _declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 133) || - (!selectConstructors && (d.kind === 195 || d.kind === 132 || d.kind === 131))) { - _declarations.push(d); - if (d.body) - definition = d; - } - }); - if (definition) { - result.push(getDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (_declarations.length) { - result.push(getDefinitionInfo(_declarations[_declarations.length - 1], symbolKind, symbolName, containerName)); - return true; - } - return false; - } function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 113) { + if (isNewExpressionTarget(location) || location.kind === 114) { if (symbol.flags & 32) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 196); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 198); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -29189,6 +31029,27 @@ var ts; } return false; } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 135) || + (!selectConstructors && (d.kind === 197 || d.kind === 134 || d.kind === 133))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName)); + return true; + } + return false; + } } function getOccurrencesAtPosition(fileName, position) { synchronizeHostData(); @@ -29197,108 +31058,108 @@ var ts; if (!node) { return undefined; } - if (node.kind === 64 || node.kind === 92 || node.kind === 90 || + if (node.kind === 65 || node.kind === 93 || node.kind === 91 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - return getReferencesForNode(node, [sourceFile], true, false, false); + return convertReferences(getReferencesForNode(node, [sourceFile], true, false, false)); } switch (node.kind) { - case 83: - case 75: - if (hasKind(node.parent, 178)) { + case 84: + case 76: + if (hasKind(node.parent, 180)) { return getIfElseOccurrences(node.parent); } break; - case 89: - if (hasKind(node.parent, 186)) { + case 90: + if (hasKind(node.parent, 188)) { return getReturnOccurrences(node.parent); } break; - case 93: - if (hasKind(node.parent, 190)) { + case 94: + if (hasKind(node.parent, 192)) { return getThrowOccurrences(node.parent); } break; - case 67: - if (hasKind(parent(parent(node)), 191)) { + case 68: + if (hasKind(parent(parent(node)), 193)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 95: - case 80: - if (hasKind(parent(node), 191)) { + case 96: + case 81: + if (hasKind(parent(node), 193)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 91: - if (hasKind(node.parent, 188)) { + case 92: + if (hasKind(node.parent, 190)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 66: - case 72: - if (hasKind(parent(parent(parent(node))), 188)) { + case 67: + case 73: + if (hasKind(parent(parent(parent(node))), 190)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 65: - case 70: - if (hasKind(node.parent, 185) || hasKind(node.parent, 184)) { + case 66: + case 71: + if (hasKind(node.parent, 187) || hasKind(node.parent, 186)) { return getBreakOrContinueStatementOccurences(node.parent); } break; - case 81: - if (hasKind(node.parent, 181) || - hasKind(node.parent, 182) || - hasKind(node.parent, 183)) { + case 82: + if (hasKind(node.parent, 183) || + hasKind(node.parent, 184) || + hasKind(node.parent, 185)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 99: - case 74: - if (hasKind(node.parent, 180) || hasKind(node.parent, 179)) { + case 100: + case 75: + if (hasKind(node.parent, 182) || hasKind(node.parent, 181)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 113: - if (hasKind(node.parent, 133)) { + case 114: + if (hasKind(node.parent, 135)) { return getConstructorOccurrences(node.parent); } break; - case 115: - case 119: - if (hasKind(node.parent, 134) || hasKind(node.parent, 135)) { + case 116: + case 120: + if (hasKind(node.parent, 136) || hasKind(node.parent, 137)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 175)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 177)) { return getModifierOccurrences(node.kind, node.parent); } } return undefined; function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 178) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 180) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 83); - for (var _i = children.length - 1; _i >= 0; _i--) { - if (pushKeywordIf(keywords, children[_i], 75)) { + pushKeywordIf(keywords, children[0], 84); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 76)) { break; } } - if (!hasKind(ifStatement.elseStatement, 178)) { + if (!hasKind(ifStatement.elseStatement, 180)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; - for (var _i_1 = 0; _i_1 < keywords.length; _i_1++) { - if (keywords[_i_1].kind === 75 && _i_1 < keywords.length - 1) { - var elseKeyword = keywords[_i_1]; - var ifKeyword = keywords[_i_1 + 1]; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 76 && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; var shouldHighlightNextKeyword = true; for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { @@ -29312,25 +31173,25 @@ var ts; textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), isWriteAccess: false }); - _i_1++; + i++; continue; } } - result.push(getReferenceEntryFromNode(keywords[_i_1])); + result.push(getReferenceEntryFromNode(keywords[i])); } return result; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 174))) { + if (!(func && hasKind(func.body, 176))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 89); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 90); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 93); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 94); }); return ts.map(keywords, getReferenceEntryFromNode); } @@ -29341,11 +31202,11 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 93); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 94); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 89); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 90); }); } return ts.map(keywords, getReferenceEntryFromNode); @@ -29355,10 +31216,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 190) { + if (node.kind === 192) { statementAccumulator.push(node); } - else if (node.kind === 191) { + else if (node.kind === 193) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -29379,39 +31240,39 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var _parent = child.parent; - if (ts.isFunctionBlock(_parent) || _parent.kind === 221) { - return _parent; + var parent_9 = child.parent; + if (ts.isFunctionBlock(parent_9) || parent_9.kind === 224) { + return parent_9; } - if (_parent.kind === 191) { - var tryStatement = _parent; + if (parent_9.kind === 193) { + var tryStatement = parent_9; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = _parent; + child = parent_9; } return undefined; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 95); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 96); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 67); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 68); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 80, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 80); + var finallyKeyword = ts.findChildOfKind(tryStatement, 81, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 81); } return ts.map(keywords, getReferenceEntryFromNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 81, 99, 74)) { - if (loopNode.kind === 179) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82, 100, 75)) { + if (loopNode.kind === 181) { var loopTokens = loopNode.getChildren(); - for (var _i = loopTokens.length - 1; _i >= 0; _i--) { - if (pushKeywordIf(keywords, loopTokens[_i], 99)) { + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 100)) { break; } } @@ -29420,20 +31281,20 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 65, 70); + pushKeywordIf(keywords, statement.getFirstToken(), 66, 71); } }); return ts.map(keywords, getReferenceEntryFromNode); } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 91); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 92); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 66, 72); + pushKeywordIf(keywords, clause.getFirstToken(), 67, 73); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 65); + pushKeywordIf(keywords, statement.getFirstToken(), 66); } }); }); @@ -29443,13 +31304,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { + case 183: + case 184: + case 185: case 181: case 182: - case 183: - case 179: - case 180: return getLoopBreakContinueOccurrences(owner); - case 188: + case 190: return getSwitchCaseDefaultOccurrences(owner); } } @@ -29460,7 +31321,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 185 || node.kind === 184) { + if (node.kind === 187 || node.kind === 186) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -29474,23 +31335,23 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var _node = statement.parent; _node; _node = _node.parent) { - switch (_node.kind) { - case 188: - if (statement.kind === 184) { + for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { + switch (node_1.kind) { + case 190: + if (statement.kind === 186) { continue; } - case 181: - case 182: case 183: - case 180: - case 179: - if (!statement.label || isLabeledBy(_node, statement.label.text)) { - return _node; + case 184: + case 185: + case 182: + case 181: + if (!statement.label || isLabeledBy(node_1, statement.label.text)) { + return node_1; } break; default: - if (ts.isFunctionLike(_node)) { + if (ts.isFunctionLike(node_1)) { return undefined; } break; @@ -29503,38 +31364,38 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 113); + return pushKeywordIf(keywords, token, 114); }); }); return ts.map(keywords, getReferenceEntryFromNode); } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 134); - tryPushAccessorKeyword(accessorDeclaration.symbol, 135); + tryPushAccessorKeyword(accessorDeclaration.symbol, 136); + tryPushAccessorKeyword(accessorDeclaration.symbol, 137); return ts.map(keywords, getReferenceEntryFromNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 115, 119); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 120); }); } } } function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; - if (declaration.flags & 112) { - if (!(container.kind === 196 || - (declaration.kind === 128 && hasKind(container, 133)))) { + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 198 || + (declaration.kind === 129 && hasKind(container, 135)))) { return undefined; } } - else if (declaration.flags & 128) { - if (container.kind !== 196) { + else if (modifier === 110) { + if (container.kind !== 198) { return undefined; } } - else if (declaration.flags & (1 | 2)) { - if (!(container.kind === 201 || container.kind === 221)) { + else if (modifier === 78 || modifier === 115) { + if (!(container.kind === 203 || container.kind === 224)) { return undefined; } } @@ -29545,18 +31406,18 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 201: - case 221: + case 203: + case 224: nodes = container.statements; break; - case 133: + case 135: nodes = container.parameters.concat(container.parent.members); break; - case 196: + case 198: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 133 && member; + return member.kind === 135 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -29574,17 +31435,17 @@ var ts; return ts.map(keywords, getReferenceEntryFromNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 108: - return 16; - case 106: - return 32; - case 107: - return 64; case 109: + return 16; + case 107: + return 32; + case 108: + return 64; + case 110: return 128; - case 77: + case 78: return 1; - case 114: + case 115: return 2; default: ts.Debug.fail(); @@ -29609,46 +31470,63 @@ var ts; return false; } } + function convertReferences(referenceSymbols) { + if (!referenceSymbols) { + return undefined; + } + var referenceEntries = []; + for (var _i = 0, _n = referenceSymbols.length; _i < _n; _i++) { + var referenceSymbol = referenceSymbols[_i]; + ts.addRange(referenceEntries, referenceSymbol.references); + } + return referenceEntries; + } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return findReferences(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - return findReferences(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return convertReferences(referencedSymbols); } - function findReferences(fileName, position, findInStrings, findInComments) { + function findReferences(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); + } + function findReferencedSymbols(fileName, position, findInStrings, findInComments) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, position); if (!node) { return undefined; } - if (node.kind !== 64 && + if (node.kind !== 65 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 64 || node.kind === 7 || node.kind === 8); + ts.Debug.assert(node.kind === 65 || node.kind === 7 || node.kind === 8); return getReferencesForNode(node, program.getSourceFiles(), false, findInStrings, findInComments); } function getReferencesForNode(node, sourceFiles, searchOnlyInCurrentFile, findInStrings, findInComments) { if (isLabelName(node)) { if (isJumpStatementTarget(node)) { var labelDefinition = getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : [getReferenceEntryFromNode(node)]; + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; } else { return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 92) { + if (node.kind === 93) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 90) { + if (node.kind === 91) { return getReferencesForSuperKeyword(node); } var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { - return [getReferenceEntryFromNode(node)]; + return undefined; } var declarations = symbol.declarations; if (!declarations || !declarations.length) { @@ -29658,15 +31536,16 @@ var ts; var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); var declaredName = getDeclaredName(symbol, node); var scope = getSymbolScope(symbol); + var symbolToIndex = []; if (scope) { result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { if (searchOnlyInCurrentFile) { ts.Debug.assert(sourceFiles.length === 1); result = []; - getReferencesInNode(sourceFiles[0], symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(sourceFiles[0], symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { var internedName = getInternedName(symbol, node, declarations); @@ -29675,48 +31554,64 @@ var ts; var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } }); } } return result; + function getDefinition(symbol) { + var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), typeInfoResolver, node); + var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + return { + containerKind: "", + containerName: "", + name: name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0) + }; + } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 208 || location.parent.kind === 212) && + (location.parent.kind === 210 || location.parent.kind === 214) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 208 || declaration.kind === 212; + return declaration.kind === 210 || declaration.kind === 214; }); } function getDeclaredName(symbol, location) { - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 160 ? d : undefined; }); - var _name; + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 162 ? d : undefined; }); + var name; if (functionExpression && functionExpression.name) { - _name = functionExpression.name.text; + name = functionExpression.name.text; } if (isImportOrExportSpecifierName(location)) { return location.getText(); } - _name = typeInfoResolver.symbolToString(symbol); - return stripQuotes(_name); + name = typeInfoResolver.symbolToString(symbol); + return stripQuotes(name); } function getInternedName(symbol, location, declarations) { if (isImportOrExportSpecifierName(location)) { return location.getText(); } - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 160 ? d : undefined; }); - var _name = functionExpression && functionExpression.name + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 162 ? d : undefined; }); + var name = functionExpression && functionExpression.name ? functionExpression.name.text : symbol.name; - return stripQuotes(_name); + return stripQuotes(name); } function stripQuotes(name) { - var _length = name.length; - if (_length >= 2 && name.charCodeAt(0) === 34 && name.charCodeAt(_length - 1) === 34) { - return name.substring(1, _length - 1); + var length = name.length; + if (length >= 2 && name.charCodeAt(0) === 34 && name.charCodeAt(length - 1) === 34) { + return name.substring(1, length - 1); } ; return name; @@ -29725,7 +31620,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 196); + return ts.getAncestor(privateDeclaration, 198); } } if (symbol.flags & 8388608) { @@ -29734,25 +31629,25 @@ var ts; if (symbol.parent || (symbol.flags & 268435456)) { return undefined; } - var _scope = undefined; - var _declarations = symbol.getDeclarations(); - if (_declarations) { - for (var _i = 0, _n = _declarations.length; _i < _n; _i++) { - var declaration = _declarations[_i]; + var scope = undefined; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, _n = declarations.length; _i < _n; _i++) { + var declaration = declarations[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; } - if (_scope && _scope !== container) { + if (scope && scope !== container) { return undefined; } - if (container.kind === 221 && !ts.isExternalModule(container)) { + if (container.kind === 224 && !ts.isExternalModule(container)) { return undefined; } - _scope = container; + scope = container; } } - return _scope; + return scope; } function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { var positions = []; @@ -29777,27 +31672,35 @@ var ts; return positions; } function getLabelReferencesInNode(container, targetLabel) { - var _result = []; + var references = []; var sourceFile = container.getSourceFile(); var labelName = targetLabel.text; var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.getWidth() !== labelName.length) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { return; } - if (_node === targetLabel || - (isJumpStatementTarget(_node) && getTargetLabel(_node, labelName) === targetLabel)) { - _result.push(getReferenceEntryFromNode(_node)); + if (node === targetLabel || + (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); } }); - return _result; + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) + }; + return [{ definition: definition, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 64: + case 65: return node.getWidth() === searchSymbolName.length; case 8: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -29814,7 +31717,7 @@ var ts; } return false; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result) { + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { var sourceFile = container.getSourceFile(); var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { - result.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); + var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } } }); } + return; + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol), + references: [] + }); + } + return result[index]; + } function isInString(position) { var token = ts.getTokenAtPosition(sourceFile, position); return token && token.kind === 8 && position > token.getStart(); @@ -29877,105 +31800,116 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 130: - case 129: case 132: case 131: - case 133: case 134: + case 133: case 135: + case 136: + case 137: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; default: return undefined; } - var _result = []; + var references = []; var sourceFile = searchSpaceNode.getSourceFile(); var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.kind !== 90) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 91) { return; } - var container = ts.getSuperContainer(_node, false); + var container = ts.getSuperContainer(node, false); if (container && (128 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - _result.push(getReferenceEntryFromNode(_node)); + references.push(getReferenceEntryFromNode(node)); } }); - return _result; + var definition = getDefinition(searchSpaceNode.symbol); + return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { - case 132: - case 131: + case 134: + case 133: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } - case 130: - case 129: - case 133: - case 134: + case 132: + case 131: case 135: + case 136: + case 137: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 221: + case 224: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 195: - case 160: + case 197: + case 162: break; default: return undefined; } - var _result = []; + var references = []; var possiblePositions; - if (searchSpaceNode.kind === 221) { + if (searchSpaceNode.kind === 224) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, _result); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); }); } else { var sourceFile = searchSpaceNode.getSourceFile(); possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, _result); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); } - return _result; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) + }, + references: references + }]; function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.kind !== 92) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 93) { return; } - var container = ts.getThisContainer(_node, false); + var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 160: - case 195: + case 162: + case 197: if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 132: - case 131: + case 134: + case 133: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 196: + case 198: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 221: - if (container.kind === 221 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(_node)); + case 224: + if (container.kind === 224 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); } break; } @@ -29983,37 +31917,37 @@ var ts; } } function populateSearchSymbolSet(symbol, location) { - var _result = [symbol]; + var result = [symbol]; if (isImportOrExportSpecifierImportSymbol(symbol)) { - _result.push(typeInfoResolver.getAliasedSymbol(symbol)); + result.push(typeInfoResolver.getAliasedSymbol(symbol)); } if (isNameOfPropertyAssignment(location)) { ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - _result.push.apply(_result, typeInfoResolver.getRootSymbols(contextualSymbol)); + result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol)); }); var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(location.parent); if (shorthandValueSymbol) { - _result.push(shorthandValueSymbol); + result.push(shorthandValueSymbol); } } ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) { if (rootSymbol !== symbol) { - _result.push(rootSymbol); + result.push(rootSymbol); } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), _result); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); } }); - return _result; + return result; } function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 196) { + if (declaration.kind === 198) { getPropertySymbolFromTypeReference(ts.getClassBaseTypeNode(declaration)); ts.forEach(ts.getClassImplementedTypeNodes(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 197) { + else if (declaration.kind === 199) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -30032,57 +31966,59 @@ var ts; } } } - function isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation) { + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { if (searchSymbols.indexOf(referenceSymbol) >= 0) { - return true; + return referenceSymbol; } - if (isImportOrExportSpecifierImportSymbol(referenceSymbol) && - searchSymbols.indexOf(typeInfoResolver.getAliasedSymbol(referenceSymbol)) >= 0) { - return true; + if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + var aliasedSymbol = typeInfoResolver.getAliasedSymbol(referenceSymbol); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } } if (isNameOfPropertyAssignment(referenceLocation)) { return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { - return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0; }); + return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); }); } return ts.forEach(typeInfoResolver.getRootSymbols(referenceSymbol), function (rootSymbol) { if (searchSymbols.indexOf(rootSymbol) >= 0) { - return true; + return rootSymbol; } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - var _result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), _result); - return ts.forEach(_result, function (s) { return searchSymbols.indexOf(s) >= 0; }); + var result_2 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_2); + return ts.forEach(result_2, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } - return false; + return undefined; }); } function getPropertySymbolsFromContextualType(node) { if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeInfoResolver.getContextualType(objectLiteral); - var _name = node.text; + var name_20 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(_name); + var unionProperty = contextualType.getProperty(name_20); if (unionProperty) { return [unionProperty]; } else { - var _result = []; + var result_3 = []; ts.forEach(contextualType.types, function (t) { - var _symbol = t.getProperty(_name); - if (_symbol) { - _result.push(_symbol); + var symbol = t.getProperty(name_20); + if (symbol) { + result_3.push(symbol); } }); - return _result; + return result_3; } } else { - var _symbol = contextualType.getProperty(_name); - if (_symbol) { - return [_symbol]; + var symbol_1 = contextualType.getProperty(name_20); + if (symbol_1) { + return [symbol_1]; } } } @@ -30120,17 +32056,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 64 && ts.isDeclarationName(node)) { + if (node.kind === 65 && ts.isDeclarationName(node)) { return true; } - var _parent = node.parent; - if (_parent) { - if (_parent.kind === 166 || _parent.kind === 165) { + var parent = node.parent; + if (parent) { + if (parent.kind === 168 || parent.kind === 167) { return true; } - else if (_parent.kind === 167 && _parent.left === node) { - var operator = _parent.operatorToken.kind; - return 52 <= operator && operator <= 63; + else if (parent.kind === 169 && parent.left === node) { + var operator = parent.operatorToken.kind; + return 53 <= operator && operator <= 64; } } return false; @@ -30140,7 +32076,7 @@ var ts; return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); } function containErrors(diagnostics) { - return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === 1; }); + return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); } function getEmitOutput(fileName) { synchronizeHostData(); @@ -30161,33 +32097,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 128: - case 193: - case 150: - case 130: case 129: - case 218: - case 219: - case 220: + case 195: + case 152: case 132: case 131: - case 133: + case 221: + case 222: + case 223: case 134: + case 133: case 135: - case 195: - case 160: - case 161: - case 217: - return 1; - case 127: + case 136: + case 137: case 197: - case 198: - case 143: - return 2; - case 196: + case 162: + case 163: + case 220: + return 1; + case 128: case 199: - return 1 | 2; case 200: + case 145: + return 2; + case 198: + case 201: + return 1 | 2; + case 202: if (node.name.kind === 8) { return 4 | 1; } @@ -30197,14 +32133,14 @@ var ts; else { return 4; } - case 207: - case 208: - case 203: - case 204: case 209: case 210: + case 205: + case 206: + case 211: + case 212: return 1 | 2 | 4; - case 221: + case 224: return 4 | 1; } return 1 | 2 | 4; @@ -30214,35 +32150,35 @@ var ts; if (isRightSideOfQualifiedName(node)) { node = node.parent; } - return node.parent.kind === 139; + return node.parent.kind === 141; } function isNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 125) { - while (root.parent && root.parent.kind === 125) + if (root.parent.kind === 126) { + while (root.parent && root.parent.kind === 126) root = root.parent; isLastClause = root.right === node; } - return root.parent.kind === 139 && !isLastClause; + return root.parent.kind === 141 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 125) { + while (node.parent.kind === 126) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 64); - if (node.parent.kind === 125 && + ts.Debug.assert(node.kind === 65); + if (node.parent.kind === 126 && node.parent.right === node && - node.parent.parent.kind === 203) { + node.parent.parent.kind === 205) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 211) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -30276,15 +32212,15 @@ var ts; return; } switch (node.kind) { - case 153: - case 125: + case 155: + case 126: case 8: - case 79: - case 94: - case 88: - case 90: - case 92: - case 64: + case 80: + case 95: + case 89: + case 91: + case 93: + case 65: break; default: return; @@ -30295,7 +32231,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 200 && + if (nodeForStartPos.parent.parent.kind === 202 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -30351,13 +32287,13 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 200 && ts.getModuleInstanceState(declaration) == 1; + return declaration.kind === 202 && ts.getModuleInstanceState(declaration) == 1; }); } } function processNode(node) { if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 64 && node.getWidth() > 0) { + if (node.kind === 65 && node.getWidth() > 0) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); @@ -30468,17 +32404,17 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 52) { - if (token.parent.kind === 193 || - token.parent.kind === 130 || - token.parent.kind === 128) { + if (tokenKind === 53) { + if (token.parent.kind === 195 || + token.parent.kind === 132 || + token.parent.kind === 129) { return ClassificationTypeNames.operator; } } - if (token.parent.kind === 167 || - token.parent.kind === 165 || - token.parent.kind === 166 || - token.parent.kind === 168) { + if (token.parent.kind === 169 || + token.parent.kind === 167 || + token.parent.kind === 168 || + token.parent.kind === 170) { return ClassificationTypeNames.operator; } } @@ -30496,30 +32432,30 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return ClassificationTypeNames.stringLiteral; } - else if (tokenKind === 64) { + else if (tokenKind === 65) { if (token) { switch (token.parent.kind) { - case 196: + case 198: if (token.parent.name === token) { return ClassificationTypeNames.className; } return; - case 127: + case 128: if (token.parent.name === token) { return ClassificationTypeNames.typeParameterName; } return; - case 197: + case 199: if (token.parent.name === token) { return ClassificationTypeNames.interfaceName; } return; - case 199: + case 201: if (token.parent.name === token) { return ClassificationTypeNames.enumName; } return; - case 200: + case 202: if (token.parent.name === token) { return ClassificationTypeNames.moduleName; } @@ -30638,9 +32574,9 @@ var ts; continue; } var descriptor = undefined; - for (var _i = 0, n = descriptors.length; _i < n; _i++) { - if (matchArray[_i + firstDescriptorCaptureIndex]) { - descriptor = descriptors[_i]; + for (var i = 0, n = descriptors.length; i < n; i++) { + if (matchArray[i + firstDescriptorCaptureIndex]) { + descriptor = descriptors[i]; } } ts.Debug.assert(descriptor !== undefined); @@ -30660,15 +32596,17 @@ var ts; return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); } function getTodoCommentsRegExp() { + // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to + // filter them out later in the final result array. var singleLineCommentStart = /(?:\/\/+\s*)/.source; var multiLineCommentStart = /(?:\/\*+\s*)/.source; var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; - var _preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; var messagePortion = "(" + literals + messageRemainder + ")"; - var regExpString = _preamble + messagePortion + endOfLineOrEndOfComment; + var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { @@ -30681,7 +32619,7 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 64) { + if (node && node.kind === 65) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -30690,8 +32628,8 @@ var ts; if (defaultLibFileName) { for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var current = declarations[_i]; - var _sourceFile = current.getSourceFile(); - if (_sourceFile && getCanonicalFileName(ts.normalizePath(_sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { + var sourceFile_1 = current.getSourceFile(); + if (sourceFile_1 && getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } } @@ -30738,6 +32676,7 @@ var ts; getQuickInfoAtPosition: getQuickInfoAtPosition, getDefinitionAtPosition: getDefinitionAtPosition, getReferencesAtPosition: getReferencesAtPosition, + findReferences: findReferences, getOccurrencesAtPosition: getOccurrencesAtPosition, getNameOrDottedNameSpan: getNameOrDottedNameSpan, getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, @@ -30771,13 +32710,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 64: + case 65: nameTable[node.text] = node.text; break; case 8: case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 213 || + node.parent.kind === 216 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -30790,40 +32729,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 154 && + node.parent.kind === 156 && node.parent.argumentExpression === node; } function createClassifier() { - var _scanner = ts.createScanner(2, false); + var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[64] = true; + noRegexTable[65] = true; noRegexTable[8] = true; noRegexTable[7] = true; noRegexTable[9] = true; - noRegexTable[92] = true; + noRegexTable[93] = true; noRegexTable[38] = true; noRegexTable[39] = true; noRegexTable[17] = true; noRegexTable[19] = true; noRegexTable[15] = true; - noRegexTable[94] = true; - noRegexTable[79] = true; + noRegexTable[95] = true; + noRegexTable[80] = true; var templateStack = []; - function isAccessibilityModifier(kind) { - switch (kind) { - case 108: - case 106: - case 107: - return true; - } - return false; - } function canFollow(keyword1, keyword2) { - if (isAccessibilityModifier(keyword1)) { - if (keyword2 === 115 || - keyword2 === 119 || - keyword2 === 113 || - keyword2 === 109) { + if (ts.isAccessibilityModifier(keyword1)) { + if (keyword2 === 116 || + keyword2 === 120 || + keyword2 === 114 || + keyword2 === 110) { return true; } return false; @@ -30861,40 +32791,40 @@ var ts; templateStack.push(11); break; } - _scanner.setText(text); + scanner.setText(text); var result = { finalLexState: 0, entries: [] }; var angleBracketStack = 0; do { - token = _scanner.scan(); + token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 36 || token === 56) && !noRegexTable[lastNonTriviaToken]) { - if (_scanner.reScanSlashToken() === 9) { + if ((token === 36 || token === 57) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 9) { token = 9; } } else if (lastNonTriviaToken === 20 && isKeyword(token)) { - token = 64; + token = 65; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 64; + token = 65; } - else if (lastNonTriviaToken === 64 && + else if (lastNonTriviaToken === 65 && token === 24) { angleBracketStack++; } else if (token === 25 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 111 || - token === 120 || - token === 118 || - token === 112 || - token === 121) { + else if (token === 112 || + token === 121 || + token === 119 || + token === 113 || + token === 122) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 64; + token = 65; } } else if (token === 11) { @@ -30909,7 +32839,7 @@ var ts; if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); if (lastTemplateStackToken === 11) { - token = _scanner.reScanTemplateToken(); + token = scanner.reScanTemplateToken(); if (token === 13) { templateStack.pop(); } @@ -30929,13 +32859,13 @@ var ts; } while (token !== 1); return result; function processToken() { - var start = _scanner.getTokenPos(); - var end = _scanner.getTextPos(); + var start = scanner.getTokenPos(); + var end = scanner.getTextPos(); addResult(end - start, classFromKind(token)); if (end >= text.length) { if (token === 8) { - var tokenText = _scanner.getTokenText(); - if (_scanner.isUnterminated()) { + var tokenText = scanner.getTokenText(); + if (scanner.isUnterminated()) { var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92) { @@ -30950,12 +32880,12 @@ var ts; } } else if (token === 3) { - if (_scanner.isUnterminated()) { + if (scanner.isUnterminated()) { result.finalLexState = 1; } } else if (ts.isTemplateLiteralKind(token)) { - if (_scanner.isUnterminated()) { + if (scanner.isUnterminated()) { if (token === 13) { result.finalLexState = 5; } @@ -30995,8 +32925,8 @@ var ts; case 25: case 26: case 27: + case 87: case 86: - case 85: case 28: case 29: case 30: @@ -31006,18 +32936,18 @@ var ts; case 44: case 48: case 49: - case 62: - case 61: case 63: - case 58: + case 62: + case 64: case 59: case 60: - case 53: + case 61: case 54: case 55: case 56: case 57: - case 52: + case 58: + case 53: case 23: return true; default: @@ -31038,38 +32968,38 @@ var ts; } } function isKeyword(token) { - return token >= 65 && token <= 124; + return token >= 66 && token <= 125; } function classFromKind(token) { if (isKeyword(token)) { - return 1; + return TokenClass.Keyword; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 2; + return TokenClass.Operator; } - else if (token >= 14 && token <= 63) { - return 0; + else if (token >= 14 && token <= 64) { + return TokenClass.Punctuation; } switch (token) { case 7: - return 6; + return TokenClass.NumberLiteral; case 8: - return 7; + return TokenClass.StringLiteral; case 9: - return 8; + return TokenClass.RegExpLiteral; case 6: case 3: case 2: - return 3; + return TokenClass.Comment; case 5: case 4: - return 4; - case 64: + return TokenClass.Whitespace; + case 65: default: if (ts.isTemplateLiteralKind(token)) { - return 7; + return TokenClass.StringLiteral; } - return 5; + return TokenClass.Identifier; } } return { getClassificationsForLine: getClassificationsForLine }; @@ -31087,7 +33017,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 221 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 224 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -31103,11 +33033,836 @@ var ts; } initializeServices(); })(ts || (ts = {})); +/// +/// +/// +/// +/// +var ts; +(function (ts) { + var server; + (function (server) { + var spaceCache = []; + function generateSpaces(n) { + if (!spaceCache[n]) { + var strBuilder = ""; + for (var i = 0; i < n; i++) { + strBuilder += " "; + } + spaceCache[n] = strBuilder; + } + return spaceCache[n]; + } + server.generateSpaces = generateSpaces; + function compareNumber(a, b) { + if (a < b) { + return -1; + } + else if (a == b) { + return 0; + } + else + return 1; + } + function compareFileStart(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file == b.file) { + var n = compareNumber(a.start.line, b.start.line); + if (n == 0) { + return compareNumber(a.start.offset, b.start.offset); + } + else + return n; + } + else { + return 1; + } + } + function formatDiag(fileName, project, diag) { + return { + start: project.compilerService.host.positionToLineOffset(fileName, diag.start), + end: project.compilerService.host.positionToLineOffset(fileName, diag.start + diag.length), + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + }; + } + function allEditsBeforePos(edits, pos) { + for (var i = 0, len = edits.length; i < len; i++) { + if (ts.textSpanEnd(edits[i].span) >= pos) { + return false; + } + } + return true; + } + var CommandNames; + (function (CommandNames) { + CommandNames.Change = "change"; + CommandNames.Close = "close"; + CommandNames.Completions = "completions"; + CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.Configure = "configure"; + CommandNames.Definition = "definition"; + CommandNames.Format = "format"; + CommandNames.Formatonkey = "formatonkey"; + CommandNames.Geterr = "geterr"; + CommandNames.NavBar = "navbar"; + CommandNames.Navto = "navto"; + CommandNames.Open = "open"; + CommandNames.Quickinfo = "quickinfo"; + CommandNames.References = "references"; + CommandNames.Reload = "reload"; + CommandNames.Rename = "rename"; + CommandNames.Saveto = "saveto"; + CommandNames.Brace = "brace"; + CommandNames.Unknown = "unknown"; + })(CommandNames = server.CommandNames || (server.CommandNames = {})); + var Errors; + (function (Errors) { + Errors.NoProject = new Error("No Project."); + })(Errors || (Errors = {})); + var Session = (function () { + function Session(host, logger) { + var _this = this; + this.host = host; + this.logger = logger; + this.pendingOperation = false; + this.fileHash = {}; + this.nextFileId = 1; + this.changeSeq = 0; + this.projectService = + new server.ProjectService(host, logger, function (eventName, project, fileName) { + _this.handleEvent(eventName, project, fileName); + }); + } + Session.prototype.handleEvent = function (eventName, project, fileName) { + var _this = this; + if (eventName == "context") { + this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); + this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n == _this.changeSeq; }, 100); + } + }; + Session.prototype.logError = function (err, cmd) { + var typedErr = err; + var msg = "Exception on executing command " + cmd; + if (typedErr.message) { + msg += ":\n" + typedErr.message; + if (typedErr.stack) { + msg += "\n" + typedErr.stack; + } + } + this.projectService.log(msg); + }; + Session.prototype.sendLineToClient = function (line) { + this.host.write(line + this.host.newLine); + }; + Session.prototype.send = function (msg) { + var json = JSON.stringify(msg); + if (this.logger.isVerbose()) { + this.logger.info(msg.type + ": " + json); + } + this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) + + '\r\n\r\n' + json); + }; + Session.prototype.event = function (info, eventName) { + var ev = { + seq: 0, + type: "event", + event: eventName, + body: info + }; + this.send(ev); + }; + Session.prototype.response = function (info, cmdName, reqSeq, errorMsg) { + if (reqSeq === void 0) { reqSeq = 0; } + var res = { + seq: 0, + type: "response", + command: cmdName, + request_seq: reqSeq, + success: !errorMsg + }; + if (!errorMsg) { + res.body = info; + } + else { + res.message = errorMsg; + } + this.send(res); + }; + Session.prototype.output = function (body, commandName, requestSequence, errorMessage) { + if (requestSequence === void 0) { requestSequence = 0; } + this.response(body, commandName, requestSequence, errorMessage); + }; + Session.prototype.semanticCheck = function (file, project) { + try { + var diags = project.compilerService.languageService.getSemanticDiagnostics(file); + if (diags) { + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); + } + } + catch (err) { + this.logError(err, "semantic check"); + } + }; + Session.prototype.syntacticCheck = function (file, project) { + try { + var diags = project.compilerService.languageService.getSyntacticDiagnostics(file); + if (diags) { + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); + } + } + catch (err) { + this.logError(err, "syntactic check"); + } + }; + Session.prototype.errorCheck = function (file, project) { + this.syntacticCheck(file, project); + this.semanticCheck(file, project); + }; + Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { + var _this = this; + if (ms === void 0) { ms = 1500; } + setTimeout(function () { + if (matchSeq(seq)) { + _this.projectService.updateProjectStructure(); + } + }, ms); + }; + Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs) { + var _this = this; + if (ms === void 0) { ms = 1500; } + if (followMs === void 0) { followMs = 200; } + if (followMs > ms) { + followMs = ms; + } + if (this.errorTimer) { + clearTimeout(this.errorTimer); + } + if (this.immediateId) { + clearImmediate(this.immediateId); + this.immediateId = undefined; + } + var index = 0; + var checkOne = function () { + if (matchSeq(seq)) { + var checkSpec = checkList[index++]; + if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, true)) { + _this.syntacticCheck(checkSpec.fileName, checkSpec.project); + _this.immediateId = setImmediate(function () { + _this.semanticCheck(checkSpec.fileName, checkSpec.project); + _this.immediateId = undefined; + if (checkList.length > index) { + _this.errorTimer = setTimeout(checkOne, followMs); + } + else { + _this.errorTimer = undefined; + } + }); + } + } + }; + if ((checkList.length > index) && (matchSeq(seq))) { + this.errorTimer = setTimeout(checkOne, ms); + } + }; + Session.prototype.getDefinition = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var definitions = compilerService.languageService.getDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + return definitions.map(function (def) { return ({ + file: def.fileName, + start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), + end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) + }); }); + }; + Session.prototype.getRenameLocations = function (line, offset, fileName, findInComments, findInStrings) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var renameInfo = compilerService.languageService.getRenameInfo(file, position); + if (!renameInfo) { + return undefined; + } + if (!renameInfo.canRename) { + return { + info: renameInfo, + locs: [] + }; + } + var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments); + if (!renameLocations) { + return undefined; + } + var bakedRenameLocs = renameLocations.map(function (location) { return ({ + file: location.fileName, + start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start), + end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)) + }); }).sort(function (a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file > b.file) { + return 1; + } + else { + if (a.start.line < b.start.line) { + return 1; + } + else if (a.start.line > b.start.line) { + return -1; + } + else { + return b.start.offset - a.start.offset; + } + } + }).reduce(function (accum, cur) { + var curFileAccum; + if (accum.length > 0) { + curFileAccum = accum[accum.length - 1]; + if (curFileAccum.file != cur.file) { + curFileAccum = undefined; + } + } + if (!curFileAccum) { + curFileAccum = { file: cur.file, locs: [] }; + accum.push(curFileAccum); + } + curFileAccum.locs.push({ start: cur.start, end: cur.end }); + return accum; + }, []); + return { info: renameInfo, locs: bakedRenameLocs }; + }; + Session.prototype.getReferences = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var references = compilerService.languageService.getReferencesAtPosition(file, position); + if (!references) { + return undefined; + } + var nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); + if (!nameInfo) { + return undefined; + } + var displayString = ts.displayPartsToString(nameInfo.displayParts); + var nameSpan = nameInfo.textSpan; + var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset; + var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var bakedRefs = references.map(function (ref) { + var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start); + var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1); + var snap = compilerService.host.getScriptSnapshot(ref.fileName); + var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); + return { + file: ref.fileName, + start: start, + lineText: lineText, + end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)), + isWriteAccess: ref.isWriteAccess + }; + }).sort(compareFileStart); + return { + refs: bakedRefs, + symbolName: nameText, + symbolStartOffset: nameColStart, + symbolDisplayString: displayString + }; + }; + Session.prototype.openClientFile = function (fileName) { + var file = ts.normalizePath(fileName); + this.projectService.openClientFile(file); + }; + Session.prototype.getQuickInfo = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); + if (!quickInfo) { + return undefined; + } + var displayString = ts.displayPartsToString(quickInfo.displayParts); + var docString = ts.displayPartsToString(quickInfo.documentation); + return { + kind: quickInfo.kind, + kindModifiers: quickInfo.kindModifiers, + start: compilerService.host.positionToLineOffset(file, quickInfo.textSpan.start), + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(quickInfo.textSpan)), + displayString: displayString, + documentation: docString + }; + }; + Session.prototype.getFormattingEditsForRange = function (line, offset, endLine, endOffset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset); + var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); + var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); + if (!edits) { + return undefined; + } + return edits.map(function (edit) { + return { + start: compilerService.host.positionToLineOffset(file, edit.span.start), + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), + newText: edit.newText ? edit.newText : "" + }; + }); + }; + Session.prototype.getFormattingEditsAfterKeystroke = function (line, offset, key, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var formatOptions = this.projectService.getFormatCodeOptions(file); + var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); + if ((key == "\n") && ((!edits) || (edits.length == 0) || allEditsBeforePos(edits, position))) { + var scriptInfo = compilerService.host.getScriptInfo(file); + if (scriptInfo) { + var lineInfo = scriptInfo.getLineInfo(line); + if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { + var lineText = lineInfo.leaf.text; + if (lineText.search("\\S") < 0) { + var editorOptions = { + IndentSize: formatOptions.IndentSize, + TabSize: formatOptions.TabSize, + NewLineCharacter: "\n", + ConvertTabsToSpaces: true + }; + var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + for (var i = 0, len = lineText.length; i < len; i++) { + if (lineText.charAt(i) == " ") { + indentPosition--; + } + else { + break; + } + } + if (indentPosition > 0) { + var spaces = generateSpaces(indentPosition); + edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces }); + } + else if (indentPosition < 0) { + edits.push({ + span: ts.createTextSpanFromBounds(position, position - indentPosition), + newText: "" + }); + } + } + } + } + } + if (!edits) { + return undefined; + } + return edits.map(function (edit) { + return { + start: compilerService.host.positionToLineOffset(file, edit.span.start), + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), + newText: edit.newText ? edit.newText : "" + }; + }); + }; + Session.prototype.getCompletions = function (line, offset, prefix, fileName) { + if (!prefix) { + prefix = ""; + } + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var completions = compilerService.languageService.getCompletionsAtPosition(file, position); + if (!completions) { + return undefined; + } + return completions.entries.reduce(function (result, entry) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) == 0)) { + result.push(entry); + } + return result; + }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); + }; + Session.prototype.getCompletionEntryDetails = function (line, offset, entryNames, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + return entryNames.reduce(function (accum, entryName) { + var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); + if (details) { + accum.push(details); + } + return accum; + }, []); + }; + Session.prototype.getSignatureHelpItems = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var helpItems = compilerService.languageService.getSignatureHelpItems(file, position); + if (!helpItems) { + return undefined; + } + var span = helpItems.applicableSpan; + var result = { + items: helpItems.items, + applicableSpan: { + start: compilerService.host.positionToLineOffset(file, span.start), + end: compilerService.host.positionToLineOffset(file, span.start + span.length) + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount + }; + return result; + }; + Session.prototype.getDiagnostics = function (delay, fileNames) { + var _this = this; + var checkList = fileNames.reduce(function (accum, fileName) { + fileName = ts.normalizePath(fileName); + var project = _this.projectService.getProjectForFile(fileName); + if (project) { + accum.push({ fileName: fileName, project: project }); + } + return accum; + }, []); + if (checkList.length > 0) { + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay); + } + }; + Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) { + var _this = this; + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (project) { + var compilerService = project.compilerService; + var start = compilerService.host.lineOffsetToPosition(file, line, offset); + var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); + if (start >= 0) { + compilerService.host.editScript(file, start, end, insertString); + this.changeSeq++; + } + this.updateProjectStructure(this.changeSeq, function (n) { return n == _this.changeSeq; }); + } + }; + Session.prototype.reload = function (fileName, tempFileName, reqSeq) { + var _this = this; + if (reqSeq === void 0) { reqSeq = 0; } + var file = ts.normalizePath(fileName); + var tmpfile = ts.normalizePath(tempFileName); + var project = this.projectService.getProjectForFile(file); + if (project) { + this.changeSeq++; + project.compilerService.host.reloadScript(file, tmpfile, function () { + _this.output(undefined, CommandNames.Reload, reqSeq); + }); + } + }; + Session.prototype.saveToTmp = function (fileName, tempFileName) { + var file = ts.normalizePath(fileName); + var tmpfile = ts.normalizePath(tempFileName); + var project = this.projectService.getProjectForFile(file); + if (project) { + project.compilerService.host.saveTo(file, tmpfile); + } + }; + Session.prototype.closeClientFile = function (fileName) { + var file = ts.normalizePath(fileName); + this.projectService.closeClientFile(file); + }; + Session.prototype.decorateNavigationBarItem = function (project, fileName, items) { + var _this = this; + if (!items) { + return undefined; + } + var compilerService = project.compilerService; + return items.map(function (item) { return ({ + text: item.text, + kind: item.kind, + kindModifiers: item.kindModifiers, + spans: item.spans.map(function (span) { return ({ + start: compilerService.host.positionToLineOffset(fileName, span.start), + end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span)) + }); }), + childItems: _this.decorateNavigationBarItem(project, fileName, item.childItems) + }); }); + }; + Session.prototype.getNavigationBarItems = function (fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var items = compilerService.languageService.getNavigationBarItems(file); + if (!items) { + return undefined; + } + return this.decorateNavigationBarItem(project, fileName, items); + }; + Session.prototype.getNavigateToItems = function (searchValue, fileName, maxResultCount) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount); + if (!navItems) { + return undefined; + } + return navItems.map(function (navItem) { + var start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start); + var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); + var bakedItem = { + name: navItem.name, + kind: navItem.kind, + file: navItem.fileName, + start: start, + end: end + }; + if (navItem.kindModifiers && (navItem.kindModifiers != "")) { + bakedItem.kindModifiers = navItem.kindModifiers; + } + if (navItem.matchKind != 'none') { + bakedItem.matchKind = navItem.matchKind; + } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + }; + Session.prototype.getBraceMatching = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); + if (!spans) { + return undefined; + } + return spans.map(function (span) { return ({ + start: compilerService.host.positionToLineOffset(file, span.start), + end: compilerService.host.positionToLineOffset(file, span.start + span.length) + }); }); + }; + Session.prototype.onMessage = function (message) { + if (this.logger.isVerbose()) { + this.logger.info("request: " + message); + var start = process.hrtime(); + } + try { + var request = JSON.parse(message); + var response; + var errorMessage; + var responseRequired = true; + switch (request.command) { + case CommandNames.Definition: { + var defArgs = request.arguments; + response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file); + break; + } + case CommandNames.References: { + var refArgs = request.arguments; + response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file); + break; + } + case CommandNames.Rename: { + var renameArgs = request.arguments; + response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings); + break; + } + case CommandNames.Open: { + var openArgs = request.arguments; + this.openClientFile(openArgs.file); + responseRequired = false; + break; + } + case CommandNames.Quickinfo: { + var quickinfoArgs = request.arguments; + response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file); + break; + } + case CommandNames.Format: { + var formatArgs = request.arguments; + response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file); + break; + } + case CommandNames.Formatonkey: { + var formatOnKeyArgs = request.arguments; + response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file); + break; + } + case CommandNames.Completions: { + var completionsArgs = request.arguments; + response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file); + break; + } + case CommandNames.CompletionDetails: { + var completionDetailsArgs = request.arguments; + response = + this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file); + break; + } + case CommandNames.SignatureHelp: { + var signatureHelpArgs = request.arguments; + response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file); + break; + } + case CommandNames.Geterr: { + var geterrArgs = request.arguments; + response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files); + responseRequired = false; + break; + } + case CommandNames.Change: { + var changeArgs = request.arguments; + this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); + responseRequired = false; + break; + } + case CommandNames.Configure: { + var configureArgs = request.arguments; + this.projectService.setHostConfiguration(configureArgs); + this.output(undefined, CommandNames.Configure, request.seq); + responseRequired = false; + break; + } + case CommandNames.Reload: { + var reloadArgs = request.arguments; + this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); + responseRequired = false; + break; + } + case CommandNames.Saveto: { + var savetoArgs = request.arguments; + this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); + responseRequired = false; + break; + } + case CommandNames.Close: { + var closeArgs = request.arguments; + this.closeClientFile(closeArgs.file); + responseRequired = false; + break; + } + case CommandNames.Navto: { + var navtoArgs = request.arguments; + response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount); + break; + } + case CommandNames.Brace: { + var braceArguments = request.arguments; + response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file); + break; + } + case CommandNames.NavBar: { + var navBarArgs = request.arguments; + response = this.getNavigationBarItems(navBarArgs.file); + break; + } + default: { + this.projectService.log("Unrecognized JSON command: " + message); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + break; + } + } + if (this.logger.isVerbose()) { + var elapsed = process.hrtime(start); + var seconds = elapsed[0]; + var nanoseconds = elapsed[1]; + var elapsedMs = ((1e9 * seconds) + nanoseconds) / 1000000.0; + var leader = "Elapsed time (in milliseconds)"; + if (!responseRequired) { + leader = "Async elapsed time (in milliseconds)"; + } + this.logger.msg(leader + ": " + elapsedMs.toFixed(4).toString(), "Perf"); + } + if (response) { + this.output(response, request.command, request.seq); + } + else if (responseRequired) { + this.output(undefined, request.command, request.seq, "No content available."); + } + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + } + this.logError(err, message); + this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message); + } + }; + return Session; + })(); + server.Session = Session; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +/// +/// +/// +/// +/// var ts; (function (ts) { var server; (function (server) { var lineCollectionCapacity = 4; + function mergeFormatOptions(formatCodeOptions, formatOptions) { + var hasOwnProperty = Object.prototype.hasOwnProperty; + Object.keys(formatOptions).forEach(function (key) { + var codeKey = key.charAt(0).toUpperCase() + key.substring(1); + if (hasOwnProperty.call(formatCodeOptions, codeKey)) { + formatCodeOptions[codeKey] = formatOptions[key]; + } + }); + } var ScriptInfo = (function () { function ScriptInfo(host, fileName, content, isOpen) { if (isOpen === void 0) { isOpen = false; } @@ -31116,8 +33871,14 @@ var ts; this.content = content; this.isOpen = isOpen; this.children = []; + this.formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); this.svc = ScriptVersionCache.fromString(content); } + ScriptInfo.prototype.setFormatOptions = function (formatOptions) { + if (formatOptions) { + mergeFormatOptions(this.formatCodeOptions, formatOptions); + } + }; ScriptInfo.prototype.close = function () { this.isOpen = false; }; @@ -31258,21 +34019,21 @@ var ts; } else { var nextLineInfo = index.lineNumberToInfo(line + 2); - len = nextLineInfo.col - lineInfo.col; + len = nextLineInfo.offset - lineInfo.offset; } - return ts.createTextSpan(lineInfo.col, len); + return ts.createTextSpan(lineInfo.offset, len); }; - LSHost.prototype.lineColToPosition = function (filename, line, col) { + LSHost.prototype.lineOffsetToPosition = function (filename, line, offset) { var script = this.filenameToScript[filename]; var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line); - return (lineInfo.col + col - 1); + return (lineInfo.offset + offset - 1); }; - LSHost.prototype.positionToLineCol = function (filename, position) { + LSHost.prototype.positionToLineOffset = function (filename, position) { var script = this.filenameToScript[filename]; var index = script.snap().index; - var lineCol = index.charOffsetToLineNumberAndPos(position); - return { line: lineCol.line, col: lineCol.col + 1 }; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; }; return LSHost; })(); @@ -31301,12 +34062,21 @@ var ts; } } var Project = (function () { - function Project(projectService) { + function Project(projectService, projectOptions) { this.projectService = projectService; + this.projectOptions = projectOptions; this.filenameToSourceFile = {}; this.updateGraphSeq = 0; - this.compilerService = new CompilerService(this); + this.openRefCount = 0; + this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); } + Project.prototype.addOpenRef = function () { + this.openRefCount++; + }; + Project.prototype.deleteOpenRef = function () { + this.openRefCount--; + return this.openRefCount; + }; Project.prototype.openReferencedFile = function (filename) { return this.projectService.openFile(filename, false); }; @@ -31321,6 +34091,9 @@ var ts; } } }; + Project.prototype.isRoot = function (info) { + return this.compilerService.host.roots.some(function (root) { return root === info; }); + }; Project.prototype.removeReferencedFile = function (info) { this.compilerService.host.removeReferencedFile(info); this.updateGraph(); @@ -31378,9 +34151,27 @@ var ts; this.eventHandler = eventHandler; this.filenameToScriptInfo = {}; this.openFileRoots = []; - this.openFilesReferenced = []; this.inferredProjects = []; + this.configuredProjects = []; + this.openFilesReferenced = []; + this.openFileRootsConfigured = []; + this.addDefaultHostConfiguration(); } + ProjectService.prototype.addDefaultHostConfiguration = function () { + this.hostConfiguration = { + formatCodeOptions: ts.clone(CompilerService.defaultFormatCodeOptions), + hostInfo: "Unknown host" + }; + }; + ProjectService.prototype.getFormatCodeOptions = function (file) { + if (file) { + var info = this.filenameToScriptInfo[file]; + if (info) { + return info.formatCodeOptions; + } + } + return this.hostConfiguration.formatCodeOptions; + }; ProjectService.prototype.watchedFileChanged = function (fileName) { var info = this.filenameToScriptInfo[fileName]; if (!info) { @@ -31399,6 +34190,25 @@ var ts; if (type === void 0) { type = "Err"; } this.psLogger.msg(msg, type); }; + ProjectService.prototype.setHostConfiguration = function (args) { + if (args.file) { + var info = this.filenameToScriptInfo[args.file]; + if (info) { + info.setFormatOptions(args.formatOptions); + this.log("Host configuration update for file " + args.file); + } + } + else { + if (args.hostInfo !== undefined) { + this.hostConfiguration.hostInfo = args.hostInfo; + this.log("Host information " + args.hostInfo, "Info"); + } + if (args.formatOptions) { + mergeFormatOptions(this.hostConfiguration.formatCodeOptions, args.formatOptions); + this.log("Format host information updated", "Info"); + } + } + }; ProjectService.prototype.closeLog = function () { this.psLogger.close(); }; @@ -31436,35 +34246,61 @@ var ts; } this.printProjects(); }; + ProjectService.prototype.updateConfiguredProjectList = function () { + var configuredProjects = []; + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + if (this.configuredProjects[i].openRefCount > 0) { + configuredProjects.push(this.configuredProjects[i]); + } + } + this.configuredProjects = configuredProjects; + }; + ProjectService.prototype.setConfiguredProjectRoot = function (info) { + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + var configuredProject = this.configuredProjects[i]; + if (configuredProject.isRoot(info)) { + info.defaultProject = configuredProject; + configuredProject.addOpenRef(); + return true; + } + } + return false; + }; ProjectService.prototype.addOpenFile = function (info) { - this.findReferencingProjects(info); - if (info.defaultProject) { - this.openFilesReferenced.push(info); + if (this.setConfiguredProjectRoot(info)) { + this.openFileRootsConfigured.push(info); } else { - info.defaultProject = this.createInferredProject(info); - var openFileRoots = []; - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - var r = this.openFileRoots[i]; - if (info.defaultProject.getSourceFile(r)) { - this.inferredProjects = - copyListRemovingItem(r.defaultProject, this.inferredProjects); - this.openFilesReferenced.push(r); - r.defaultProject = info.defaultProject; + this.findReferencingProjects(info); + if (info.defaultProject) { + this.openFilesReferenced.push(info); + } + else { + info.defaultProject = this.createInferredProject(info); + var openFileRoots = []; + for (var i = 0, len = this.openFileRoots.length; i < len; i++) { + var r = this.openFileRoots[i]; + if (info.defaultProject.getSourceFile(r)) { + this.inferredProjects = + copyListRemovingItem(r.defaultProject, this.inferredProjects); + this.openFilesReferenced.push(r); + r.defaultProject = info.defaultProject; + } + else { + openFileRoots.push(r); + } } - else { - openFileRoots.push(r); - } + this.openFileRoots = openFileRoots; + this.openFileRoots.push(info); } - this.openFileRoots = openFileRoots; - this.openFileRoots.push(info); } + this.updateConfiguredProjectList(); }; ProjectService.prototype.closeOpenFile = function (info) { var openFileRoots = []; var removedProject; for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - if (info == this.openFileRoots[i]) { + if (info === this.openFileRoots[i]) { removedProject = info.defaultProject; } else { @@ -31472,8 +34308,27 @@ var ts; } } this.openFileRoots = openFileRoots; + if (!removedProject) { + var openFileRootsConfigured = []; + for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { + if (info === this.openFileRootsConfigured[i]) { + if (info.defaultProject.deleteOpenRef() === 0) { + removedProject = info.defaultProject; + } + } + else { + openFileRootsConfigured.push(this.openFileRootsConfigured[i]); + } + } + this.openFileRootsConfigured = openFileRootsConfigured; + } if (removedProject) { - this.inferredProjects = copyListRemovingItem(removedProject, this.inferredProjects); + if (removedProject.isConfiguredProject()) { + this.configuredProjects = copyListRemovingItem(removedProject, this.configuredProjects); + } + else { + this.inferredProjects = copyListRemovingItem(removedProject, this.inferredProjects); + } var openFilesReferenced = []; var orphanFiles = []; for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { @@ -31500,14 +34355,22 @@ var ts; var referencingProjects = []; info.defaultProject = undefined; for (var i = 0, len = this.inferredProjects.length; i < len; i++) { - this.inferredProjects[i].updateGraph(); - if (this.inferredProjects[i] != excludedProject) { - if (this.inferredProjects[i].getSourceFile(info)) { - info.defaultProject = this.inferredProjects[i]; - referencingProjects.push(this.inferredProjects[i]); + var inferredProject = this.inferredProjects[i]; + inferredProject.updateGraph(); + if (inferredProject != excludedProject) { + if (inferredProject.getSourceFile(info)) { + info.defaultProject = inferredProject; + referencingProjects.push(inferredProject); } } } + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + var configuredProject = this.configuredProjects[i]; + configuredProject.updateGraph(); + if (configuredProject.getSourceFile(info)) { + info.defaultProject = configuredProject; + } + } return referencingProjects; }; ProjectService.prototype.updateProjectStructure = function () { @@ -31553,7 +34416,6 @@ var ts; }; ProjectService.prototype.openFile = function (fileName, openedByClient) { var _this = this; - if (openedByClient === void 0) { openedByClient = false; } fileName = ts.normalizePath(fileName); var info = ts.lookUp(this.filenameToScriptInfo, fileName); if (!info) { @@ -31567,6 +34429,7 @@ var ts; } } if (content !== undefined) { + var indentSize; info = new ScriptInfo(this.host, fileName, content, openedByClient); this.filenameToScriptInfo[fileName] = info; if (!info.isOpen) { @@ -31581,8 +34444,44 @@ var ts; } return info; }; - ProjectService.prototype.openClientFile = function (filename) { - var info = this.openFile(filename, true); + ProjectService.prototype.findConfigFile = function (searchPath) { + while (true) { + var fileName = ts.combinePaths(searchPath, "tsconfig.json"); + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + }; + ProjectService.prototype.openClientFile = function (fileName) { + var searchPath = ts.normalizePath(ts.getDirectoryPath(fileName)); + this.log("Search path: " + searchPath, "Info"); + var configFileName = this.findConfigFile(searchPath); + if (configFileName) { + this.log("Config file name: " + configFileName, "Info"); + } + else { + this.log("no config file"); + } + if (configFileName) { + configFileName = getAbsolutePath(configFileName, searchPath); + } + if (configFileName && (!this.configProjectIsActive(configFileName))) { + var configResult = this.openConfigFile(configFileName, fileName); + if (!configResult.success) { + this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + } + else { + this.log("Opened configuration file " + configFileName, "Info"); + this.configuredProjects.push(configResult.project); + } + } + var info = this.openFile(fileName, true); this.addOpenFile(info); this.printProjects(); return info; @@ -31595,18 +34494,6 @@ var ts; } this.printProjects(); }; - ProjectService.prototype.getProjectsReferencingFile = function (filename) { - var scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); - if (scriptInfo) { - var projects = []; - for (var i = 0, len = this.inferredProjects.length; i < len; i++) { - if (this.inferredProjects[i].getSourceFile(scriptInfo)) { - projects.push(this.inferredProjects[i]); - } - } - return projects; - } - }; ProjectService.prototype.getProjectForFile = function (filename) { var scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); if (scriptInfo) { @@ -31618,9 +34505,9 @@ var ts; if (scriptInfo) { this.psLogger.startGroup(); this.psLogger.info("Projects for " + filename); - var projects = this.getProjectsReferencingFile(filename); + var projects = this.findReferencingProjects(scriptInfo); for (var i = 0, len = projects.length; i < len; i++) { - this.psLogger.info("Inferred Project " + i.toString()); + this.psLogger.info("Project " + i.toString()); } this.psLogger.endGroup(); } @@ -31637,17 +34524,40 @@ var ts; this.psLogger.info(project.filesToString()); this.psLogger.info("-----------------------------------------------"); } - this.psLogger.info("Open file roots: "); + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + var project = this.configuredProjects[i]; + project.updateGraph(); + this.psLogger.info("Project (configured) " + (i + this.inferredProjects.length).toString()); + this.psLogger.info(project.filesToString()); + this.psLogger.info("-----------------------------------------------"); + } + this.psLogger.info("Open file roots of inferred projects: "); for (var i = 0, len = this.openFileRoots.length; i < len; i++) { this.psLogger.info(this.openFileRoots[i].fileName); } - this.psLogger.info("Open files referenced: "); + this.psLogger.info("Open files referenced by inferred or configured projects: "); for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - this.psLogger.info(this.openFilesReferenced[i].fileName); + var fileInfo = this.openFilesReferenced[i].fileName; + if (this.openFilesReferenced[i].defaultProject.isConfiguredProject()) { + fileInfo += " (configured)"; + } + this.psLogger.info(fileInfo); + } + this.psLogger.info("Open file roots of configured projects: "); + for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { + this.psLogger.info(this.openFileRootsConfigured[i].fileName); } this.psLogger.endGroup(); }; - ProjectService.prototype.openConfigFile = function (configFilename) { + ProjectService.prototype.configProjectIsActive = function (fileName) { + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + if (this.configuredProjects[i].projectFilename == fileName) { + return true; + } + } + return false; + }; + ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { configFilename = ts.normalizePath(configFilename); var dirPath = ts.getDirectoryPath(configFilename); var rawConfig = ts.readConfigFile(configFilename); @@ -31655,32 +34565,27 @@ var ts; return { errorMsg: "tsconfig syntax error" }; } else { - var parsedCommandLine = ts.parseConfigFile(rawConfig); - if (parsedCommandLine.errors) { + var parsedCommandLine = ts.parseConfigFile(rawConfig, dirPath); + if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { errorMsg: "tsconfig option errors" }; } else if (parsedCommandLine.fileNames) { - var proj = this.createProject(configFilename); + var projectOptions = { + files: parsedCommandLine.fileNames, + compilerOptions: parsedCommandLine.options + }; + var proj = this.createProject(configFilename, projectOptions); for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) { var rootFilename = parsedCommandLine.fileNames[i]; - var normRootFilename = ts.normalizePath(rootFilename); - normRootFilename = getAbsolutePath(normRootFilename, dirPath); - if (this.host.fileExists(normRootFilename)) { - var info = this.openFile(normRootFilename); + if (ts.sys.fileExists(rootFilename)) { + var info = this.openFile(rootFilename, clientFileName == rootFilename); proj.addRoot(info); } else { return { errorMsg: "specified file " + rootFilename + " not found" }; } } - var projectOptions = { - files: parsedCommandLine.fileNames, - compilerOptions: parsedCommandLine.options - }; - if (rawConfig.formatCodeOptions) { - projectOptions.formatCodeOptions = rawConfig.formatCodeOptions; - } - proj.setProjectOptions(projectOptions); + proj.finishGraph(); return { success: true, project: proj }; } else { @@ -31688,23 +34593,25 @@ var ts; } } }; - ProjectService.prototype.createProject = function (projectFilename) { - var eproj = new Project(this); - eproj.projectFilename = projectFilename; - return eproj; + ProjectService.prototype.createProject = function (projectFilename, projectOptions) { + var project = new Project(this, projectOptions); + project.projectFilename = projectFilename; + return project; }; return ProjectService; })(); server.ProjectService = ProjectService; var CompilerService = (function () { - function CompilerService(project) { + function CompilerService(project, opt) { this.project = project; - this.settings = ts.getDefaultCompilerOptions(); this.documentRegistry = ts.createDocumentRegistry(); - this.formatCodeOptions = CompilerService.defaultFormatCodeOptions; this.host = new LSHost(project.projectService.host, project); - this.settings.target = 1; - this.host.setCompilationSettings(this.settings); + if (opt) { + this.setCompilerOptions(opt); + } + else { + this.setCompilerOptions(ts.getDefaultCompilerOptions()); + } this.languageService = ts.createLanguageService(this.host, this.documentRegistry); this.classifier = ts.createClassifier(); } @@ -31756,7 +34663,7 @@ var ts; _super.call(this); this.lineIndex = new LineIndex(); this.endBranch = []; - this.state = 2; + this.state = CharRangeSection.Entire; this.initialText = ""; this.trailingText = ""; this.suppressTrailingText = false; @@ -31842,15 +34749,15 @@ var ts; }; EditWalker.prototype.post = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { if (lineCollection == this.lineCollectionAtBranch) { - this.state = 4; + this.state = CharRangeSection.End; } this.stack.length--; return undefined; }; EditWalker.prototype.pre = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { var currentNode = this.stack[this.stack.length - 1]; - if ((this.state == 2) && (nodeType == 1)) { - this.state = 1; + if ((this.state == CharRangeSection.Entire) && (nodeType == CharRangeSection.Start)) { + this.state = CharRangeSection.Start; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; } @@ -31863,14 +34770,14 @@ var ts; return new LineNode(); } switch (nodeType) { - case 0: + case CharRangeSection.PreStart: this.goSubtree = false; - if (this.state != 4) { + if (this.state != CharRangeSection.End) { currentNode.add(lineCollection); } break; - case 1: - if (this.state == 4) { + case CharRangeSection.Start: + if (this.state == CharRangeSection.End) { this.goSubtree = false; } else { @@ -31879,8 +34786,8 @@ var ts; this.startPath[this.startPath.length] = child; } break; - case 2: - if (this.state != 4) { + case CharRangeSection.Entire: + if (this.state != CharRangeSection.End) { child = fresh(lineCollection); currentNode.add(child); this.startPath[this.startPath.length] = child; @@ -31893,11 +34800,11 @@ var ts; } } break; - case 3: + case CharRangeSection.Mid: this.goSubtree = false; break; - case 4: - if (this.state != 4) { + case CharRangeSection.End: + if (this.state != CharRangeSection.End) { this.goSubtree = false; } else { @@ -31908,9 +34815,9 @@ var ts; } } break; - case 5: + case CharRangeSection.PostEnd: this.goSubtree = false; - if (this.state != 1) { + if (this.state != CharRangeSection.Start) { currentNode.add(lineCollection); } break; @@ -31921,10 +34828,10 @@ var ts; return lineCollection; }; EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state == 1) { + if (this.state == CharRangeSection.Start) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state == 2) { + else if (this.state == CharRangeSection.Entire) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -32074,7 +34981,7 @@ var ts; LineIndexSnapshot.prototype.getLineMapper = function () { var _this = this; return (function (line) { - return _this.index.lineNumberToInfo(line).col; + return _this.index.lineNumberToInfo(line).offset; }); }; LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { @@ -32108,7 +35015,7 @@ var ts; else { return { line: lineNumber, - col: this.root.charCount() + offset: this.root.charCount() }; } }; @@ -32187,7 +35094,7 @@ var ts; else if (deleteLength > 0) { var e = pos + deleteLength; var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.col == 0))) { + if ((lineInfo && (lineInfo.offset == 0))) { deleteLength += lineInfo.text.length; if (newText) { newText = newText + lineInfo.text; @@ -32304,25 +35211,25 @@ var ts; var childCharCount = child.charCount(); var adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0); + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); adjustedStart -= childCharCount; child = this.children[++childIndex]; childCharCount = child.charCount(); } if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2)) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { return; } } else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1)) { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { return; } var adjustedLength = rangeLength - (childCharCount - adjustedStart); child = this.children[++childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, 3)) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { return; } adjustedLength -= childCharCount; @@ -32330,7 +35237,7 @@ var ts; childCharCount = child.charCount(); } if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4)) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { return; } } @@ -32339,7 +35246,7 @@ var ts; var clen = this.children.length; if (childIndex < (clen - 1)) { for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, 5); + this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); } } } @@ -32349,14 +35256,14 @@ var ts; if (!childInfo.child) { return { line: lineNumber, - col: charOffset + offset: charOffset }; } else if (childInfo.childIndex < this.children.length) { if (childInfo.child.isLeaf()) { return { line: childInfo.lineNumber, - col: childInfo.charOffset, + offset: childInfo.charOffset, text: (childInfo.child).text, leaf: (childInfo.child) }; @@ -32368,7 +35275,7 @@ var ts; } else { var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { line: this.lineCount(), col: lineInfo.leaf.charCount() }; + return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; } }; LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { @@ -32376,13 +35283,13 @@ var ts; if (!childInfo.child) { return { line: lineNumber, - col: charOffset + offset: charOffset }; } else if (childInfo.child.isLeaf()) { return { line: lineNumber, - col: childInfo.charOffset, + offset: childInfo.charOffset, text: (childInfo.child).text, leaf: (childInfo.child) }; @@ -32551,769 +35458,8 @@ var ts; })(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var spaceCache = [" ", " ", " ", " "]; - function generateSpaces(n) { - if (!spaceCache[n]) { - var strBuilder = ""; - for (var i = 0; i < n; i++) { - strBuilder += " "; - } - spaceCache[n] = strBuilder; - } - return spaceCache[n]; - } - function compareNumber(a, b) { - if (a < b) { - return -1; - } - else if (a == b) { - return 0; - } - else - return 1; - } - function compareFileStart(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file == b.file) { - var n = compareNumber(a.start.line, b.start.line); - if (n == 0) { - return compareNumber(a.start.col, b.start.col); - } - else - return n; - } - else { - return 1; - } - } - function formatDiag(fileName, project, diag) { - return { - start: project.compilerService.host.positionToLineCol(fileName, diag.start), - end: project.compilerService.host.positionToLineCol(fileName, diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") - }; - } - function allEditsBeforePos(edits, pos) { - for (var i = 0, len = edits.length; i < len; i++) { - if (ts.textSpanEnd(edits[i].span) >= pos) { - return false; - } - } - return true; - } - var CommandNames; - (function (CommandNames) { - CommandNames.Change = "change"; - CommandNames.Close = "close"; - CommandNames.Completions = "completions"; - CommandNames.CompletionDetails = "completionEntryDetails"; - CommandNames.Definition = "definition"; - CommandNames.Format = "format"; - CommandNames.Formatonkey = "formatonkey"; - CommandNames.Geterr = "geterr"; - CommandNames.NavBar = "navbar"; - CommandNames.Navto = "navto"; - CommandNames.Open = "open"; - CommandNames.Quickinfo = "quickinfo"; - CommandNames.References = "references"; - CommandNames.Reload = "reload"; - CommandNames.Rename = "rename"; - CommandNames.Saveto = "saveto"; - CommandNames.Brace = "brace"; - CommandNames.Unknown = "unknown"; - })(CommandNames = server.CommandNames || (server.CommandNames = {})); - var Errors; - (function (Errors) { - Errors.NoProject = new Error("No Project."); - })(Errors || (Errors = {})); - var Session = (function () { - function Session(host, logger) { - var _this = this; - this.host = host; - this.logger = logger; - this.pendingOperation = false; - this.fileHash = {}; - this.nextFileId = 1; - this.changeSeq = 0; - this.projectService = - new server.ProjectService(host, logger, function (eventName, project, fileName) { - _this.handleEvent(eventName, project, fileName); - }); - } - Session.prototype.handleEvent = function (eventName, project, fileName) { - var _this = this; - if (eventName == "context") { - this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n == _this.changeSeq; }, 100); - } - }; - Session.prototype.logError = function (err, cmd) { - var typedErr = err; - var msg = "Exception on executing command " + cmd; - if (typedErr.message) { - msg += ":\n" + typedErr.message; - if (typedErr.stack) { - msg += "\n" + typedErr.stack; - } - } - this.projectService.log(msg); - }; - Session.prototype.sendLineToClient = function (line) { - this.host.write(line + this.host.newLine); - }; - Session.prototype.send = function (msg) { - var json = JSON.stringify(msg); - if (this.logger.isVerbose()) { - this.logger.info(msg.type + ": " + json); - } - this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) + - '\r\n\r\n' + json); - }; - Session.prototype.event = function (info, eventName) { - var ev = { - seq: 0, - type: "event", - event: eventName, - body: info - }; - this.send(ev); - }; - Session.prototype.response = function (info, cmdName, reqSeq, errorMsg) { - if (reqSeq === void 0) { reqSeq = 0; } - var res = { - seq: 0, - type: "response", - command: cmdName, - request_seq: reqSeq, - success: !errorMsg - }; - if (!errorMsg) { - res.body = info; - } - else { - res.message = errorMsg; - } - this.send(res); - }; - Session.prototype.output = function (body, commandName, requestSequence, errorMessage) { - if (requestSequence === void 0) { requestSequence = 0; } - this.response(body, commandName, requestSequence, errorMessage); - }; - Session.prototype.semanticCheck = function (file, project) { - try { - var diags = project.compilerService.languageService.getSemanticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); - } - } - catch (err) { - this.logError(err, "semantic check"); - } - }; - Session.prototype.syntacticCheck = function (file, project) { - try { - var diags = project.compilerService.languageService.getSyntacticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); - } - } - catch (err) { - this.logError(err, "syntactic check"); - } - }; - Session.prototype.errorCheck = function (file, project) { - this.syntacticCheck(file, project); - this.semanticCheck(file, project); - }; - Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { - var _this = this; - if (ms === void 0) { ms = 1500; } - setTimeout(function () { - if (matchSeq(seq)) { - _this.projectService.updateProjectStructure(); - } - }, ms); - }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs) { - var _this = this; - if (ms === void 0) { ms = 1500; } - if (followMs === void 0) { followMs = 200; } - if (followMs > ms) { - followMs = ms; - } - if (this.errorTimer) { - clearTimeout(this.errorTimer); - } - if (this.immediateId) { - clearImmediate(this.immediateId); - this.immediateId = undefined; - } - var index = 0; - var checkOne = function () { - if (matchSeq(seq)) { - var checkSpec = checkList[index++]; - if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, true)) { - _this.syntacticCheck(checkSpec.fileName, checkSpec.project); - _this.immediateId = setImmediate(function () { - _this.semanticCheck(checkSpec.fileName, checkSpec.project); - _this.immediateId = undefined; - if (checkList.length > index) { - _this.errorTimer = setTimeout(checkOne, followMs); - } - else { - _this.errorTimer = undefined; - } - }); - } - } - }; - if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = setTimeout(checkOne, ms); - } - }; - Session.prototype.getDefinition = function (line, col, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); - var definitions = compilerService.languageService.getDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - return definitions.map(function (def) { return ({ - file: def.fileName, - start: compilerService.host.positionToLineCol(def.fileName, def.textSpan.start), - end: compilerService.host.positionToLineCol(def.fileName, ts.textSpanEnd(def.textSpan)) - }); }); - }; - Session.prototype.getRenameLocations = function (line, col, fileName, findInComments, findInStrings) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); - var renameInfo = compilerService.languageService.getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: [] - }; - } - var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments); - if (!renameLocations) { - return undefined; - } - var bakedRenameLocs = renameLocations.map(function (location) { return ({ - file: location.fileName, - start: compilerService.host.positionToLineCol(location.fileName, location.textSpan.start), - end: compilerService.host.positionToLineCol(location.fileName, ts.textSpanEnd(location.textSpan)) - }); }).sort(function (a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file > b.file) { - return 1; - } - else { - if (a.start.line < b.start.line) { - return 1; - } - else if (a.start.line > b.start.line) { - return -1; - } - else { - return b.start.col - a.start.col; - } - } - }).reduce(function (accum, cur) { - var curFileAccum; - if (accum.length > 0) { - curFileAccum = accum[accum.length - 1]; - if (curFileAccum.file != cur.file) { - curFileAccum = undefined; - } - } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - accum.push(curFileAccum); - } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - return accum; - }, []); - return { info: renameInfo, locs: bakedRenameLocs }; - }; - Session.prototype.getReferences = function (line, col, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); - var references = compilerService.languageService.getReferencesAtPosition(file, position); - if (!references) { - return undefined; - } - var nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = compilerService.host.positionToLineCol(file, nameSpan.start).col; - var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var bakedRefs = references.map(function (ref) { - var start = compilerService.host.positionToLineCol(ref.fileName, ref.textSpan.start); - var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1); - var snap = compilerService.host.getScriptSnapshot(ref.fileName); - var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start: start, - lineText: lineText, - end: compilerService.host.positionToLineCol(ref.fileName, ts.textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess - }; - }).sort(compareFileStart); - return { - refs: bakedRefs, - symbolName: nameText, - symbolStartCol: nameColStart, - symbolDisplayString: displayString - }; - }; - Session.prototype.openClientFile = function (fileName) { - var file = ts.normalizePath(fileName); - this.projectService.openClientFile(file); - }; - Session.prototype.getQuickInfo = function (line, col, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); - var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); - if (!quickInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); - return { - kind: quickInfo.kind, - kindModifiers: quickInfo.kindModifiers, - start: compilerService.host.positionToLineCol(file, quickInfo.textSpan.start), - end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(quickInfo.textSpan)), - displayString: displayString, - documentation: docString - }; - }; - Session.prototype.getFormattingEditsForRange = function (line, col, endLine, endCol, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var startPosition = compilerService.host.lineColToPosition(file, line, col); - var endPosition = compilerService.host.lineColToPosition(file, endLine, endCol); - var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, compilerService.formatCodeOptions); - if (!edits) { - return undefined; - } - return edits.map(function (edit) { - return { - start: compilerService.host.positionToLineCol(file, edit.span.start), - end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); - }; - Session.prototype.getFormattingEditsAfterKeystroke = function (line, col, key, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); - var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, compilerService.formatCodeOptions); - if ((key == "\n") && ((!edits) || (edits.length == 0) || allEditsBeforePos(edits, position))) { - var scriptInfo = compilerService.host.getScriptInfo(file); - if (scriptInfo) { - var lineInfo = scriptInfo.getLineInfo(line); - if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { - var lineText = lineInfo.leaf.text; - if (lineText.search("\\S") < 0) { - var editorOptions = { - IndentSize: 4, - TabSize: 4, - NewLineCharacter: "\n", - ConvertTabsToSpaces: true - }; - var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); - for (var i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { - indentPosition--; - } - else { - break; - } - } - if (indentPosition > 0) { - var spaces = generateSpaces(indentPosition); - edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces }); - } - else if (indentPosition < 0) { - edits.push({ - span: ts.createTextSpanFromBounds(position, position - indentPosition), - newText: "" - }); - } - } - } - } - } - if (!edits) { - return undefined; - } - return edits.map(function (edit) { - return { - start: compilerService.host.positionToLineCol(file, edit.span.start), - end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); - }; - Session.prototype.getCompletions = function (line, col, prefix, fileName) { - if (!prefix) { - prefix = ""; - } - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); - var completions = compilerService.languageService.getCompletionsAtPosition(file, position); - if (!completions) { - return undefined; - } - return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || entry.name.indexOf(prefix) == 0) { - result.push(entry); - } - return result; - }, []); - }; - Session.prototype.getCompletionEntryDetails = function (line, col, entryNames, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); - return entryNames.reduce(function (accum, entryName) { - var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); - if (details) { - accum.push(details); - } - return accum; - }, []); - }; - Session.prototype.getDiagnostics = function (delay, fileNames) { - var _this = this; - var checkList = fileNames.reduce(function (accum, fileName) { - fileName = ts.normalizePath(fileName); - var project = _this.projectService.getProjectForFile(fileName); - if (project) { - accum.push({ fileName: fileName, project: project }); - } - return accum; - }, []); - if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay); - } - }; - Session.prototype.change = function (line, col, endLine, endCol, insertString, fileName) { - var _this = this; - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (project) { - var compilerService = project.compilerService; - var start = compilerService.host.lineColToPosition(file, line, col); - var end = compilerService.host.lineColToPosition(file, endLine, endCol); - if (start >= 0) { - compilerService.host.editScript(file, start, end, insertString); - this.changeSeq++; - } - this.updateProjectStructure(this.changeSeq, function (n) { return n == _this.changeSeq; }); - } - }; - Session.prototype.reload = function (fileName, tempFileName, reqSeq) { - var _this = this; - if (reqSeq === void 0) { reqSeq = 0; } - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); - if (project) { - this.changeSeq++; - project.compilerService.host.reloadScript(file, tmpfile, function () { - _this.output(undefined, CommandNames.Reload, reqSeq); - }); - } - }; - Session.prototype.saveToTmp = function (fileName, tempFileName) { - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); - if (project) { - project.compilerService.host.saveTo(file, tmpfile); - } - }; - Session.prototype.closeClientFile = function (fileName) { - var file = ts.normalizePath(fileName); - this.projectService.closeClientFile(file); - }; - Session.prototype.decorateNavigationBarItem = function (project, fileName, items) { - var _this = this; - if (!items) { - return undefined; - } - var compilerService = project.compilerService; - return items.map(function (item) { return ({ - text: item.text, - kind: item.kind, - kindModifiers: item.kindModifiers, - spans: item.spans.map(function (span) { return ({ - start: compilerService.host.positionToLineCol(fileName, span.start), - end: compilerService.host.positionToLineCol(fileName, ts.textSpanEnd(span)) - }); }), - childItems: _this.decorateNavigationBarItem(project, fileName, item.childItems) - }); }); - }; - Session.prototype.getNavigationBarItems = function (fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var items = compilerService.languageService.getNavigationBarItems(file); - if (!items) { - return undefined; - } - return this.decorateNavigationBarItem(project, fileName, items); - }; - Session.prototype.getNavigateToItems = function (searchValue, fileName, maxResultCount) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount); - if (!navItems) { - return undefined; - } - return navItems.map(function (navItem) { - var start = compilerService.host.positionToLineCol(navItem.fileName, navItem.textSpan.start); - var end = compilerService.host.positionToLineCol(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); - var bakedItem = { - name: navItem.name, - kind: navItem.kind, - file: navItem.fileName, - start: start, - end: end - }; - if (navItem.kindModifiers && (navItem.kindModifiers != "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.matchKind != 'none') { - bakedItem.matchKind = navItem.matchKind; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }; - Session.prototype.getBraceMatching = function (line, col, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); - var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); - if (!spans) { - return undefined; - } - return spans.map(function (span) { return ({ - start: compilerService.host.positionToLineCol(file, span.start), - end: compilerService.host.positionToLineCol(file, span.start + span.length) - }); }); - }; - Session.prototype.onMessage = function (message) { - if (this.logger.isVerbose()) { - this.logger.info("request: " + message); - var start = process.hrtime(); - } - try { - var request = JSON.parse(message); - var response; - var errorMessage; - var responseRequired = true; - switch (request.command) { - case CommandNames.Definition: { - var defArgs = request.arguments; - response = this.getDefinition(defArgs.line, defArgs.col, defArgs.file); - break; - } - case CommandNames.References: { - var refArgs = request.arguments; - response = this.getReferences(refArgs.line, refArgs.col, refArgs.file); - break; - } - case CommandNames.Rename: { - var renameArgs = request.arguments; - response = this.getRenameLocations(renameArgs.line, renameArgs.col, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings); - break; - } - case CommandNames.Open: { - var openArgs = request.arguments; - this.openClientFile(openArgs.file); - responseRequired = false; - break; - } - case CommandNames.Quickinfo: { - var quickinfoArgs = request.arguments; - response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.col, quickinfoArgs.file); - break; - } - case CommandNames.Format: { - var formatArgs = request.arguments; - response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.col, formatArgs.endLine, formatArgs.endCol, formatArgs.file); - break; - } - case CommandNames.Formatonkey: { - var formatOnKeyArgs = request.arguments; - response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.col, formatOnKeyArgs.key, formatOnKeyArgs.file); - break; - } - case CommandNames.Completions: { - var completionsArgs = request.arguments; - response = this.getCompletions(request.arguments.line, request.arguments.col, completionsArgs.prefix, request.arguments.file); - break; - } - case CommandNames.CompletionDetails: { - var completionDetailsArgs = request.arguments; - response = this.getCompletionEntryDetails(request.arguments.line, request.arguments.col, completionDetailsArgs.entryNames, request.arguments.file); - break; - } - case CommandNames.Geterr: { - var geterrArgs = request.arguments; - response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files); - responseRequired = false; - break; - } - case CommandNames.Change: { - var changeArgs = request.arguments; - this.change(changeArgs.line, changeArgs.col, changeArgs.endLine, changeArgs.endCol, changeArgs.insertString, changeArgs.file); - responseRequired = false; - break; - } - case CommandNames.Reload: { - var reloadArgs = request.arguments; - this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); - break; - } - case CommandNames.Saveto: { - var savetoArgs = request.arguments; - this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - responseRequired = false; - break; - } - case CommandNames.Close: { - var closeArgs = request.arguments; - this.closeClientFile(closeArgs.file); - responseRequired = false; - break; - } - case CommandNames.Navto: { - var navtoArgs = request.arguments; - response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount); - break; - } - case CommandNames.Brace: { - var braceArguments = request.arguments; - response = this.getBraceMatching(braceArguments.line, braceArguments.col, braceArguments.file); - break; - } - case CommandNames.NavBar: { - var navBarArgs = request.arguments; - response = this.getNavigationBarItems(navBarArgs.file); - break; - } - default: { - this.projectService.log("Unrecognized JSON command: " + message); - this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); - break; - } - } - if (this.logger.isVerbose()) { - var elapsed = process.hrtime(start); - var seconds = elapsed[0]; - var nanoseconds = elapsed[1]; - var elapsedMs = ((1e9 * seconds) + nanoseconds) / 1000000.0; - var leader = "Elapsed time (in milliseconds)"; - if (!responseRequired) { - leader = "Async elapsed time (in milliseconds)"; - } - this.logger.msg(leader + ": " + elapsedMs.toFixed(4).toString(), "Perf"); - } - if (response) { - this.output(response, request.command, request.seq); - } - else if (responseRequired) { - this.output(undefined, request.command, request.seq, "No content available."); - } - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - } - this.logError(err, message); - this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message); - } - }; - return Session; - })(); - server.Session = Session; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); +/// +/// var ts; (function (ts) { var server; diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index 8f71dc4ee08..3181d423310 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -74,192 +74,195 @@ declare module "typescript" { BarBarToken = 49, QuestionToken = 50, ColonToken = 51, - EqualsToken = 52, - PlusEqualsToken = 53, - MinusEqualsToken = 54, - AsteriskEqualsToken = 55, - SlashEqualsToken = 56, - PercentEqualsToken = 57, - LessThanLessThanEqualsToken = 58, - GreaterThanGreaterThanEqualsToken = 59, - GreaterThanGreaterThanGreaterThanEqualsToken = 60, - AmpersandEqualsToken = 61, - BarEqualsToken = 62, - CaretEqualsToken = 63, - Identifier = 64, - BreakKeyword = 65, - CaseKeyword = 66, - CatchKeyword = 67, - ClassKeyword = 68, - ConstKeyword = 69, - ContinueKeyword = 70, - DebuggerKeyword = 71, - DefaultKeyword = 72, - DeleteKeyword = 73, - DoKeyword = 74, - ElseKeyword = 75, - EnumKeyword = 76, - ExportKeyword = 77, - ExtendsKeyword = 78, - FalseKeyword = 79, - FinallyKeyword = 80, - ForKeyword = 81, - FunctionKeyword = 82, - IfKeyword = 83, - ImportKeyword = 84, - InKeyword = 85, - InstanceOfKeyword = 86, - NewKeyword = 87, - NullKeyword = 88, - ReturnKeyword = 89, - SuperKeyword = 90, - SwitchKeyword = 91, - ThisKeyword = 92, - ThrowKeyword = 93, - TrueKeyword = 94, - TryKeyword = 95, - TypeOfKeyword = 96, - VarKeyword = 97, - VoidKeyword = 98, - WhileKeyword = 99, - WithKeyword = 100, - AsKeyword = 101, - ImplementsKeyword = 102, - InterfaceKeyword = 103, - LetKeyword = 104, - PackageKeyword = 105, - PrivateKeyword = 106, - ProtectedKeyword = 107, - PublicKeyword = 108, - StaticKeyword = 109, - YieldKeyword = 110, - AnyKeyword = 111, - BooleanKeyword = 112, - ConstructorKeyword = 113, - DeclareKeyword = 114, - GetKeyword = 115, - ModuleKeyword = 116, - RequireKeyword = 117, - NumberKeyword = 118, - SetKeyword = 119, - StringKeyword = 120, - SymbolKeyword = 121, - TypeKeyword = 122, - FromKeyword = 123, - OfKeyword = 124, - QualifiedName = 125, - ComputedPropertyName = 126, - TypeParameter = 127, - Parameter = 128, - PropertySignature = 129, - PropertyDeclaration = 130, - MethodSignature = 131, - MethodDeclaration = 132, - Constructor = 133, - GetAccessor = 134, - SetAccessor = 135, - CallSignature = 136, - ConstructSignature = 137, - IndexSignature = 138, - TypeReference = 139, - FunctionType = 140, - ConstructorType = 141, - TypeQuery = 142, - TypeLiteral = 143, - ArrayType = 144, - TupleType = 145, - UnionType = 146, - ParenthesizedType = 147, - ObjectBindingPattern = 148, - ArrayBindingPattern = 149, - BindingElement = 150, - ArrayLiteralExpression = 151, - ObjectLiteralExpression = 152, - PropertyAccessExpression = 153, - ElementAccessExpression = 154, - CallExpression = 155, - NewExpression = 156, - TaggedTemplateExpression = 157, - TypeAssertionExpression = 158, - ParenthesizedExpression = 159, - FunctionExpression = 160, - ArrowFunction = 161, - DeleteExpression = 162, - TypeOfExpression = 163, - VoidExpression = 164, - PrefixUnaryExpression = 165, - PostfixUnaryExpression = 166, - BinaryExpression = 167, - ConditionalExpression = 168, - TemplateExpression = 169, - YieldExpression = 170, - SpreadElementExpression = 171, - OmittedExpression = 172, - TemplateSpan = 173, - Block = 174, - VariableStatement = 175, - EmptyStatement = 176, - ExpressionStatement = 177, - IfStatement = 178, - DoStatement = 179, - WhileStatement = 180, - ForStatement = 181, - ForInStatement = 182, - ForOfStatement = 183, - ContinueStatement = 184, - BreakStatement = 185, - ReturnStatement = 186, - WithStatement = 187, - SwitchStatement = 188, - LabeledStatement = 189, - ThrowStatement = 190, - TryStatement = 191, - DebuggerStatement = 192, - VariableDeclaration = 193, - VariableDeclarationList = 194, - FunctionDeclaration = 195, - ClassDeclaration = 196, - InterfaceDeclaration = 197, - TypeAliasDeclaration = 198, - EnumDeclaration = 199, - ModuleDeclaration = 200, - ModuleBlock = 201, - CaseBlock = 202, - ImportEqualsDeclaration = 203, - ImportDeclaration = 204, - ImportClause = 205, - NamespaceImport = 206, - NamedImports = 207, - ImportSpecifier = 208, - ExportAssignment = 209, - ExportDeclaration = 210, - NamedExports = 211, - ExportSpecifier = 212, - ExternalModuleReference = 213, - CaseClause = 214, - DefaultClause = 215, - HeritageClause = 216, - CatchClause = 217, - PropertyAssignment = 218, - ShorthandPropertyAssignment = 219, - EnumMember = 220, - SourceFile = 221, - SyntaxList = 222, - Count = 223, - FirstAssignment = 52, - LastAssignment = 63, - FirstReservedWord = 65, - LastReservedWord = 100, - FirstKeyword = 65, - LastKeyword = 124, - FirstFutureReservedWord = 102, - LastFutureReservedWord = 110, - FirstTypeNode = 139, - LastTypeNode = 147, + AtToken = 52, + EqualsToken = 53, + PlusEqualsToken = 54, + MinusEqualsToken = 55, + AsteriskEqualsToken = 56, + SlashEqualsToken = 57, + PercentEqualsToken = 58, + LessThanLessThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, + AmpersandEqualsToken = 62, + BarEqualsToken = 63, + CaretEqualsToken = 64, + Identifier = 65, + BreakKeyword = 66, + CaseKeyword = 67, + CatchKeyword = 68, + ClassKeyword = 69, + ConstKeyword = 70, + ContinueKeyword = 71, + DebuggerKeyword = 72, + DefaultKeyword = 73, + DeleteKeyword = 74, + DoKeyword = 75, + ElseKeyword = 76, + EnumKeyword = 77, + ExportKeyword = 78, + ExtendsKeyword = 79, + FalseKeyword = 80, + FinallyKeyword = 81, + ForKeyword = 82, + FunctionKeyword = 83, + IfKeyword = 84, + ImportKeyword = 85, + InKeyword = 86, + InstanceOfKeyword = 87, + NewKeyword = 88, + NullKeyword = 89, + ReturnKeyword = 90, + SuperKeyword = 91, + SwitchKeyword = 92, + ThisKeyword = 93, + ThrowKeyword = 94, + TrueKeyword = 95, + TryKeyword = 96, + TypeOfKeyword = 97, + VarKeyword = 98, + VoidKeyword = 99, + WhileKeyword = 100, + WithKeyword = 101, + AsKeyword = 102, + ImplementsKeyword = 103, + InterfaceKeyword = 104, + LetKeyword = 105, + PackageKeyword = 106, + PrivateKeyword = 107, + ProtectedKeyword = 108, + PublicKeyword = 109, + StaticKeyword = 110, + YieldKeyword = 111, + AnyKeyword = 112, + BooleanKeyword = 113, + ConstructorKeyword = 114, + DeclareKeyword = 115, + GetKeyword = 116, + ModuleKeyword = 117, + RequireKeyword = 118, + NumberKeyword = 119, + SetKeyword = 120, + StringKeyword = 121, + SymbolKeyword = 122, + TypeKeyword = 123, + FromKeyword = 124, + OfKeyword = 125, + QualifiedName = 126, + ComputedPropertyName = 127, + TypeParameter = 128, + Parameter = 129, + Decorator = 130, + PropertySignature = 131, + PropertyDeclaration = 132, + MethodSignature = 133, + MethodDeclaration = 134, + Constructor = 135, + GetAccessor = 136, + SetAccessor = 137, + CallSignature = 138, + ConstructSignature = 139, + IndexSignature = 140, + TypeReference = 141, + FunctionType = 142, + ConstructorType = 143, + TypeQuery = 144, + TypeLiteral = 145, + ArrayType = 146, + TupleType = 147, + UnionType = 148, + ParenthesizedType = 149, + ObjectBindingPattern = 150, + ArrayBindingPattern = 151, + BindingElement = 152, + ArrayLiteralExpression = 153, + ObjectLiteralExpression = 154, + PropertyAccessExpression = 155, + ElementAccessExpression = 156, + CallExpression = 157, + NewExpression = 158, + TaggedTemplateExpression = 159, + TypeAssertionExpression = 160, + ParenthesizedExpression = 161, + FunctionExpression = 162, + ArrowFunction = 163, + DeleteExpression = 164, + TypeOfExpression = 165, + VoidExpression = 166, + PrefixUnaryExpression = 167, + PostfixUnaryExpression = 168, + BinaryExpression = 169, + ConditionalExpression = 170, + TemplateExpression = 171, + YieldExpression = 172, + SpreadElementExpression = 173, + OmittedExpression = 174, + TemplateSpan = 175, + Block = 176, + VariableStatement = 177, + EmptyStatement = 178, + ExpressionStatement = 179, + IfStatement = 180, + DoStatement = 181, + WhileStatement = 182, + ForStatement = 183, + ForInStatement = 184, + ForOfStatement = 185, + ContinueStatement = 186, + BreakStatement = 187, + ReturnStatement = 188, + WithStatement = 189, + SwitchStatement = 190, + LabeledStatement = 191, + ThrowStatement = 192, + TryStatement = 193, + DebuggerStatement = 194, + VariableDeclaration = 195, + VariableDeclarationList = 196, + FunctionDeclaration = 197, + ClassDeclaration = 198, + InterfaceDeclaration = 199, + TypeAliasDeclaration = 200, + EnumDeclaration = 201, + ModuleDeclaration = 202, + ModuleBlock = 203, + CaseBlock = 204, + ImportEqualsDeclaration = 205, + ImportDeclaration = 206, + ImportClause = 207, + NamespaceImport = 208, + NamedImports = 209, + ImportSpecifier = 210, + ExportAssignment = 211, + ExportDeclaration = 212, + NamedExports = 213, + ExportSpecifier = 214, + MissingDeclaration = 215, + ExternalModuleReference = 216, + CaseClause = 217, + DefaultClause = 218, + HeritageClause = 219, + CatchClause = 220, + PropertyAssignment = 221, + ShorthandPropertyAssignment = 222, + EnumMember = 223, + SourceFile = 224, + SyntaxList = 225, + Count = 226, + FirstAssignment = 53, + LastAssignment = 64, + FirstReservedWord = 66, + LastReservedWord = 101, + FirstKeyword = 66, + LastKeyword = 125, + FirstFutureReservedWord = 103, + LastFutureReservedWord = 111, + FirstTypeNode = 141, + LastTypeNode = 149, FirstPunctuation = 14, - LastPunctuation = 63, + LastPunctuation = 64, FirstToken = 0, - LastToken = 124, + LastToken = 125, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -267,8 +270,8 @@ declare module "typescript" { FirstTemplateToken = 10, LastTemplateToken = 13, FirstBinaryOperator = 24, - LastBinaryOperator = 63, - FirstNode = 125, + LastBinaryOperator = 64, + FirstNode = 126, } const enum NodeFlags { Export = 1, @@ -284,6 +287,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -293,10 +297,11 @@ declare module "typescript" { DisallowIn = 2, Yield = 4, GeneratorParameter = 8, - ThisNodeHasError = 16, - ParserGeneratedFlags = 31, - ThisNodeOrAnySubNodesHasError = 32, - HasAggregatedChildData = 64, + Decorator = 16, + ThisNodeHasError = 32, + ParserGeneratedFlags = 63, + ThisNodeOrAnySubNodesHasError = 64, + HasAggregatedChildData = 128, } const enum RelationComparisonResult { Succeeded = 1, @@ -307,6 +312,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -337,6 +343,9 @@ declare module "typescript" { interface ComputedPropertyName extends Node { expression: Expression; } + interface Decorator extends Node { + expression: LeftHandSideExpression; + } interface TypeParameterDeclaration extends Declaration { name: Identifier; constraint?: TypeNode; @@ -516,6 +525,9 @@ declare module "typescript" { name?: Identifier; body: Block | Expression; } + interface ArrowFunction extends Expression, FunctionLikeDeclaration { + equalsGreaterThanToken: Node; + } interface LiteralExpression extends PrimaryExpression { text: string; isUnterminated?: boolean; @@ -725,7 +737,8 @@ declare module "typescript" { type ExportSpecifier = ImportOrExportSpecifier; interface ExportAssignment extends Declaration, ModuleElement { isExportEquals?: boolean; - expression: Expression; + expression?: Expression; + type?: TypeNode; } interface FileReference extends TextRange { fileName: string; @@ -760,14 +773,14 @@ declare module "typescript" { interface Program extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; /** - * Emits the javascript and declaration files. If targetSourceFile is not specified, then - * the javascript and declaration files will be produced for all the files in this program. - * If targetSourceFile is specified, then only the javascript and declaration for that + * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then + * the JavaScript and declaration files will be produced for all the files in this program. + * If targetSourceFile is specified, then only the JavaScript and declaration for that * specific file will be generated. * * If writeFile is not specified then the writeFile callback from the compiler host will be - * used for writing the javascript and declaration files. Otherwise, the writeFile parameter - * will be invoked when writing the javascript and declaration files. + * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter + * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; @@ -886,9 +899,10 @@ declare module "typescript" { NotAccessible = 1, CannotBeNamed = 2, } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; interface SymbolVisibilityResult { accessibility: SymbolAccessibility; - aliasesToMakeVisible?: ImportEqualsDeclaration[]; + aliasesToMakeVisible?: AnyImportSyntax[]; errorSymbolName?: string; errorNode?: Node; } @@ -896,20 +910,22 @@ declare module "typescript" { errorModuleName?: string; } interface EmitResolver { - getGeneratedNameForNode(node: Node): string; - getExpressionNameSubstitution(node: Identifier): string; - hasExportDefaultValue(node: SourceFile): boolean; - isReferencedAliasDeclaration(node: Node): boolean; + hasGlobalName(name: string): boolean; + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isUnknownIdentifier(location: Node, name: string): boolean; + resolvesToSomeValue(location: Node, name: string): boolean; getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { @@ -1016,6 +1032,7 @@ declare module "typescript" { ContextChecked = 64, EnumValuesComputed = 128, BlockScopedBindingInLoop = 256, + EmitDecorate = 512, } interface NodeLinks { resolvedType?: Type; @@ -1135,17 +1152,6 @@ declare module "typescript" { interface TypeMapper { (t: Type): Type; } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - } - interface InferenceContext { - typeParameters: TypeParameter[]; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - failedTypeParameterIndex?: number; - } interface DiagnosticMessage { key: string; category: DiagnosticCategory; @@ -1442,7 +1448,8 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; - function createCompilerHost(options: CompilerOptions): CompilerHost; + function findConfigFile(searchPath: string): string; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; @@ -1556,6 +1563,7 @@ declare module "typescript" { getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + findReferences(fileName: string, position: number): ReferencedSymbol[]; getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getOutliningSpans(fileName: string): OutliningSpan[]; @@ -1642,6 +1650,10 @@ declare module "typescript" { containerKind: string; containerName: string; } + interface ReferencedSymbol { + definition: DefinitionInfo; + references: ReferenceEntry[]; + } enum SymbolDisplayPartKind { aliasName = 0, className = 1, diff --git a/bin/typescript.js b/bin/typescript.js index 9e939631006..2a8a4725b29 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -68,192 +68,195 @@ var ts; SyntaxKind[SyntaxKind["BarBarToken"] = 49] = "BarBarToken"; SyntaxKind[SyntaxKind["QuestionToken"] = 50] = "QuestionToken"; SyntaxKind[SyntaxKind["ColonToken"] = 51] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 52] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 53] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 54] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 55] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 56] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 57] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 58] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 59] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 60] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 61] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 62] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 63] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 64] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 65] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 66] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 67] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 68] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 69] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 70] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 71] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 72] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 73] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 74] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 75] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 76] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 77] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 78] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 79] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 80] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 81] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 82] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 83] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 84] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 85] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 86] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 87] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 88] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 89] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 90] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 91] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 92] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 93] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 94] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 95] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 96] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 97] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 98] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 99] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 100] = "WithKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 101] = "AsKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 102] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 103] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 104] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 105] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 106] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 107] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 108] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 109] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 110] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 111] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 112] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 113] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 114] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 115] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 116] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 117] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 118] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 119] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 120] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 121] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 122] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 123] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 124] = "OfKeyword"; - SyntaxKind[SyntaxKind["QualifiedName"] = 125] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 126] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 127] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 128] = "Parameter"; - SyntaxKind[SyntaxKind["PropertySignature"] = 129] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 130] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 131] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 132] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 133] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 134] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 135] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 136] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 137] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 138] = "IndexSignature"; - SyntaxKind[SyntaxKind["TypeReference"] = 139] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 140] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 141] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 142] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 143] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 144] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 145] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 146] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 147] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 148] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 149] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 150] = "BindingElement"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 151] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 152] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 153] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 154] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 155] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 156] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 157] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 158] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 159] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 160] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 161] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 162] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 163] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 164] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 165] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 166] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 167] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 168] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 169] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 170] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 171] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 172] = "OmittedExpression"; - SyntaxKind[SyntaxKind["TemplateSpan"] = 173] = "TemplateSpan"; - SyntaxKind[SyntaxKind["Block"] = 174] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 175] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 176] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 177] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 178] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 179] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 180] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 181] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 182] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 183] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 184] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 185] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 186] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 187] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 188] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 189] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 190] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 191] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 192] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 193] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 194] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 195] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 196] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 197] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 198] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 199] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 200] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 201] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 202] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 203] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 204] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 205] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 206] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 207] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 208] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 209] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 210] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 211] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 212] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 213] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["CaseClause"] = 214] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 215] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 216] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 217] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 218] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 219] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 220] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 221] = "SourceFile"; - SyntaxKind[SyntaxKind["SyntaxList"] = 222] = "SyntaxList"; - SyntaxKind[SyntaxKind["Count"] = 223] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = 52] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 63] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 65] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 100] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 65] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 124] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 139] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 147] = "LastTypeNode"; + SyntaxKind[SyntaxKind["AtToken"] = 52] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 53] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 54] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 55] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 56] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 57] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 58] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 59] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 60] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 62] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 63] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 64] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 65] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 66] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 67] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 68] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 69] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 70] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 71] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 72] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 73] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 74] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 75] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 76] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 77] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 78] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 79] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 80] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 81] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 82] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 83] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 84] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 85] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 86] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 87] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 88] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 89] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 90] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 91] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 92] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 93] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 94] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 95] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 96] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 97] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 98] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 99] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 100] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 101] = "WithKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 102] = "AsKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 112] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 113] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 117] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 118] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 119] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 120] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 121] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 122] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 123] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 124] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 125] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 126] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 127] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 128] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 129] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 130] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 131] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 132] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 133] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 134] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 135] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 136] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 137] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 138] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 139] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 140] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypeReference"] = 141] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 142] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 143] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 144] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 145] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 146] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 147] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 148] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 149] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 150] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 151] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 152] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 153] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 154] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 155] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 156] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 157] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 158] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 159] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 160] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 161] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 162] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 163] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 164] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 165] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 166] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 167] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 168] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 169] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 170] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 171] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 172] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 173] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 174] = "OmittedExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 175] = "TemplateSpan"; + SyntaxKind[SyntaxKind["Block"] = 176] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 177] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 178] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 179] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 180] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 181] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 182] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 183] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 184] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 185] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 186] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 187] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 188] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 189] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 190] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 191] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 192] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 193] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 194] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 195] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 196] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 197] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 198] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 199] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 200] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 201] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 202] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 203] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 204] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 205] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 206] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 207] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 208] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 209] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 210] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 211] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 212] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 213] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 214] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 215] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 216] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["CaseClause"] = 217] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 218] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 219] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 220] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 221] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 222] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 223] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 224] = "SourceFile"; + SyntaxKind[SyntaxKind["SyntaxList"] = 225] = "SyntaxList"; + SyntaxKind[SyntaxKind["Count"] = 226] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 125] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 141] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 149] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 63] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 124] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 125] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -261,8 +264,8 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 63] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 125] = "FirstNode"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 126] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -279,6 +282,7 @@ var ts; NodeFlags[NodeFlags["Let"] = 4096] = "Let"; NodeFlags[NodeFlags["Const"] = 8192] = "Const"; NodeFlags[NodeFlags["OctalLiteral"] = 16384] = "OctalLiteral"; + NodeFlags[NodeFlags["ExportContext"] = 32768] = "ExportContext"; NodeFlags[NodeFlags["Modifier"] = 499] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 12288] = "BlockScoped"; @@ -289,10 +293,11 @@ var ts; ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; ParserContextFlags[ParserContextFlags["Yield"] = 4] = "Yield"; ParserContextFlags[ParserContextFlags["GeneratorParameter"] = 8] = "GeneratorParameter"; - ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; - ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 32] = "ThisNodeOrAnySubNodesHasError"; - ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 64] = "HasAggregatedChildData"; + ParserContextFlags[ParserContextFlags["Decorator"] = 16] = "Decorator"; + ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 32] = "ThisNodeHasError"; + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 63] = "ParserGeneratedFlags"; + ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; + ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); var ParserContextFlags = ts.ParserContextFlags; (function (RelationComparisonResult) { @@ -408,6 +413,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 64] = "ContextChecked"; NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 128] = "EnumValuesComputed"; NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 256] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 512] = "EmitDecorate"; })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var NodeCheckFlags = ts.NodeCheckFlags; (function (TypeFlags) { @@ -597,6 +603,7 @@ var ts; })(ts.CharacterCodes || (ts.CharacterCodes = {})); var CharacterCodes = ts.CharacterCodes; })(ts || (ts = {})); +/// var ts; (function (ts) { (function (Ternary) { @@ -664,9 +671,9 @@ var ts; if (array) { result = []; for (var _i = 0, _n = array.length; _i < _n; _i++) { - var _item = array[_i]; - if (f(_item)) { - result.push(_item); + var item_1 = array[_i]; + if (f(item_1)) { + result.push(item_1); } } } @@ -698,9 +705,9 @@ var ts; if (array) { result = []; for (var _i = 0, _n = array.length; _i < _n; _i++) { - var _item = array[_i]; - if (!contains(result, _item)) { - result.push(_item); + var item_2 = array[_i]; + if (!contains(result, item_2)) { + result.push(item_2); } } } @@ -717,9 +724,11 @@ var ts; } ts.sum = sum; function addRange(to, from) { - for (var _i = 0, _n = from.length; _i < _n; _i++) { - var v = from[_i]; - to.push(v); + if (to && from) { + for (var _i = 0, _n = from.length; _i < _n; _i++) { + var v = from[_i]; + to.push(v); + } } } ts.addRange = addRange; @@ -749,6 +758,35 @@ var ts; return ~low; } ts.binarySearch = binarySearch; + function reduceLeft(array, f, initial) { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + function reduceRight(array, f, initial) { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + ts.reduceRight = reduceRight; var hasOwnProperty = Object.prototype.hasOwnProperty; function hasProperty(map, key) { return hasOwnProperty.call(map, key); @@ -780,9 +818,9 @@ var ts; for (var id in first) { result[id] = first[id]; } - for (var _id in second) { - if (!hasProperty(result, _id)) { - result[_id] = second[_id]; + for (var id in second) { + if (!hasProperty(result, id)) { + result[id] = second[id]; } } return result; @@ -810,14 +848,6 @@ var ts; return hasProperty(map, key) ? map[key] : undefined; } ts.lookUp = lookUp; - function mapToArray(map) { - var result = []; - for (var id in map) { - result.push(map[id]); - } - return result; - } - ts.mapToArray = mapToArray; function copyMap(source, target) { for (var p in source) { target[p] = source[p]; @@ -1043,6 +1073,9 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { + // Get root length of http://www.website.com/folder1/foler2/ + // In this example the root is: http://www.website.com/ + // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { @@ -1212,6 +1245,7 @@ var ts; Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { ts.sys = (function () { @@ -1286,9 +1320,9 @@ var ts; var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); for (var _i = 0, _n = files.length; _i < _n; _i++) { - var _name = files[_i]; - if (!extension || ts.fileExtensionIs(_name, extension)) { - result.push(ts.combinePaths(path, _name)); + var name_1 = files[_i]; + if (!extension || ts.fileExtensionIs(name_1, extension)) { + result.push(ts.combinePaths(path, name_1)); } } var subfolders = getNames(folder.subfolders); @@ -1393,8 +1427,8 @@ var ts; } } for (var _a = 0, _b = directories.length; _a < _b; _a++) { - var _current = directories[_a]; - visitDirectory(_current); + var current = directories[_a]; + visitDirectory(current); } } } @@ -1463,559 +1497,573 @@ var ts; } })(); })(ts || (ts = {})); +/// var ts; (function (ts) { ts.Diagnostics = { - Unterminated_string_literal: { code: 1002, category: 1, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: 1, key: "Identifier expected." }, - _0_expected: { code: 1005, category: 1, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: 1, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: 1, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: 1, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: 1, key: "Unexpected token." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: 1, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: 1, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: 1, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: 1, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: 1, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: 1, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: 1, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: 1, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: 1, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: 1, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: 1, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: 1, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: 1, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: 1, key: "A class declaration can only have one 'implements' clause." }, - Accessibility_modifier_already_seen: { code: 1028, category: 1, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: 1, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: 1, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: 1, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: 1, key: "An interface declaration cannot have an 'implements' clause." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: 1, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: 1, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: 1, key: "Statements are not allowed in ambient contexts." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: 1, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: 1, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: 1, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: 1, key: "A 'declare' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: 1, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: 1, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: 1, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: 1, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: 1, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: 1, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: 1, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: 1, key: "A 'get' accessor cannot have parameters." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: 1, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - Enum_member_must_have_initializer: { code: 1061, category: 1, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: 1, key: "An export assignment cannot be used in an internal module." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: 1, key: "Ambient enum elements can only have integer literal initializers." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: 1, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: 1, key: "A 'declare' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: 1, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: 1, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: 1, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: 1, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: 1, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: 1, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: 1, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: 1, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: 1, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: 1, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: 1, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: 1, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: 1, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: 1, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: 1, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: 1, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: 1, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: 1, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: 1, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: 1, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: 1, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: 1, key: "Expression expected." }, - Type_expected: { code: 1110, category: 1, key: "Type expected." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: 1, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: 1, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: 1, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: 1, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: 1, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: 1, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: 1, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: 1, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: 1, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: 1, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: 1, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: 1, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: 1, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: 1, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: 1, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: 1, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: 1, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: 1, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: 1, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: 1, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: 1, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: 1, key: "Type reference expected." }, - Variable_declaration_expected: { code: 1134, category: 1, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: 1, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: 1, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: 1, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: 1, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: 1, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: 1, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: 1, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: 1, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: 1, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: 1, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: 1, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: 1, key: "Import declarations in an internal module cannot reference an external module." }, - Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: 1, key: "Cannot compile external modules unless the '--module' flag is provided." }, - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: 1, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: 1, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: 1, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: 1, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: 1, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_must_be_initialized: { code: 1155, category: 1, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1, key: "'let' declarations can only be declared inside a block." }, - Unterminated_template_literal: { code: 1160, category: 1, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: 1, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: 1, key: "An object member cannot be declared optional." }, - yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1, key: "'yield' expression must be contained_within a generator declaration." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: 1, key: "Computed property names are not allowed in enums." }, - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: 1, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: 1, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: 1, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: 1, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: 1, key: "A computed property name in an interface must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: 1, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: 1, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: 1, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: 1, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: 1, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: 1, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: 1, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: 1, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: 1, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: 1, key: "Unexpected token. '{' expected." }, - Property_destructuring_pattern_expected: { code: 1180, category: 1, key: "Property destructuring pattern expected." }, - Array_element_destructuring_pattern_expected: { code: 1181, category: 1, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: 1, key: "A destructuring declaration must have an initializer." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: 1, key: "Destructuring declarations are not allowed in ambient contexts." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: 1, key: "An implementation cannot be declared in ambient contexts." }, - Modifiers_cannot_appear_here: { code: 1184, category: 1, key: "Modifiers cannot appear here." }, - Merge_conflict_marker_encountered: { code: 1185, category: 1, key: "Merge conflict marker encountered." }, - A_rest_element_cannot_have_an_initializer: { code: 1186, category: 1, key: "A rest element cannot have an initializer." }, - A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: 1, key: "A parameter property may not be a binding pattern." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: 1, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: 1, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: 1, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, - An_import_declaration_cannot_have_modifiers: { code: 1191, category: 1, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export_or_export_assignment: { code: 1192, category: 1, key: "External module '{0}' has no default export or export assignment." }, - An_export_declaration_cannot_have_modifiers: { code: 1193, category: 1, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: 1, key: "Export declarations are not permitted in an internal module." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: 1, key: "Catch clause variable name must be an identifier." }, - Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: 1, key: "Catch clause variable cannot have a type annotation." }, - Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: 1, key: "Catch clause variable cannot have an initializer." }, - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: 1, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, - Unterminated_Unicode_escape_sequence: { code: 1199, category: 1, key: "Unterminated Unicode escape sequence." }, - Duplicate_identifier_0: { code: 2300, category: 1, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: 1, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: 1, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: 1, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_an_external_module: { code: 2306, category: 1, key: "File '{0}' is not an external module." }, - Cannot_find_external_module_0: { code: 2307, category: 1, key: "Cannot find external module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: 1, key: "A module cannot have more than one export assignment." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: 1, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: 1, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: 1, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: 1, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: 1, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: 1, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: 1, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: 1, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: 1, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: 1, key: "Cannot find global type '{0}'." }, - Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: 1, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: 1, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: 1, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: 1, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: 1, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: 1, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: 1, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: 1, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: 1, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: 1, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: 1, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_body: { code: 2331, category: 1, key: "'this' cannot be referenced in a module body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: 1, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: 1, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: 1, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: 1, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: 1, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: 1, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: 1, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: 1, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: 1, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: 1, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: 1, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: 1, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: 1, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: 1, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: 1, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: 1, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: 1, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: 1, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: 1, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: 1, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: 1, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: 1, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: 1, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: 1, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: 1, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: 1, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: 1, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: 1, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: 1, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: 1, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: 1, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: 1, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: 1, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: 1, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: 1, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: 1, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: 1, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: 1, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: 1, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: 1, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: 1, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: 1, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: 1, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: 1, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: 1, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: 1, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: 1, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: 1, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: 1, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: 1, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: 1, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: 1, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: 1, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: 1, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: 1, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: 1, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: 1, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: 1, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: 1, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: 1, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: 1, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: 1, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: 1, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: 1, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: 1, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: 1, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: 1, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: 1, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: 1, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: 1, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: 1, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: 1, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: 1, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: 1, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: 1, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: 1, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: 1, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: 1, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: 1, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: 1, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: 1, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: 1, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: 1, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: 1, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: 1, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: 1, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: 1, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: 1, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: 1, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: 1, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: 1, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: 1, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, - A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: 1, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: 1, key: "Ambient external modules cannot be nested in other modules." }, - Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: 1, key: "Ambient external module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: 1, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: 1, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: 1, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: 1, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: 1, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: 1, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: 1, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: 1, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: 1, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: 1, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: 1, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: 1, key: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: 1, key: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: 1, key: "Left-hand side of assignment expression cannot be a constant." }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: 1, key: "Cannot redeclare block-scoped variable '{0}'." }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: 1, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: 1, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: 1, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: 1, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: 1, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: 1, key: "An AMD module cannot have multiple name assignments." }, - Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: 1, key: "Type '{0}' has no property '{1}' and no string index signature." }, - Type_0_has_no_property_1: { code: 2460, category: 1, key: "Type '{0}' has no property '{1}'." }, - Type_0_is_not_an_array_type: { code: 2461, category: 1, key: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: 1, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: 1, key: "A binding pattern parameter cannot be optional in an implementation signature." }, - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: 1, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, - this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: 1, key: "'this' cannot be referenced in a computed property name." }, - super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: 1, key: "'super' cannot be referenced in a computed property name." }, - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: 1, key: "A computed property name cannot reference a type parameter from its containing type." }, - Cannot_find_global_value_0: { code: 2468, category: 1, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: 1, key: "The '{0}' operator cannot be applied to type 'symbol'." }, - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: 1, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: 1, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: 1, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: 1, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: 1, key: "In 'const' enum declarations member initializer must be constant expression." }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: 1, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: 1, key: "A const enum member can only be accessed using a string literal." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: 1, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: 1, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: 1, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: 1, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: 1, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: 1, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, - Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: 1, key: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: 1, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: 1, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: 1, key: "Invalid left-hand side in 'for...of' statement." }, - The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: 1, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, - The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: 1, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: 1, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: 1, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: 1, key: "Cannot redeclare identifier '{0}' in catch clause" }, - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: 1, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: 1, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2461, category: 1, key: "Type '{0}' is not an array type or a string type." }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: 1, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: 1, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: 1, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: 1, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: 1, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: 1, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: 1, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: 1, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: 1, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: 1, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: 1, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: 1, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: 1, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: 1, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: 1, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: 1, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: 1, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: 1, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: 1, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: 1, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: 1, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: 1, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: 1, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: 1, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: 1, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: 1, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: 1, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: 1, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: 1, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: 1, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: 1, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: 1, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: 1, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: 1, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: 1, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: 1, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: 1, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: 1, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: 1, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: 1, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: 1, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: 1, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: 1, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: 1, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: 1, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: 1, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: 1, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: 1, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: 1, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: 1, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: 1, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: 1, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: 1, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: 1, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: 1, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: 1, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: 1, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: 1, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: 1, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: 1, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: 1, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: 1, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: 1, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: 1, key: "Unsupported file encoding." }, - Unknown_compiler_option_0: { code: 5023, category: 1, key: "Unknown compiler option '{0}'." }, - Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: 1, key: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: 1, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: 1, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: 1, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: 1, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: 1, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: 1, key: "Option 'project' cannot be mixed with source files on a command line." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: 2, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: 2, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: 2, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: 2, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: 2, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: 2, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: 2, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: 2, key: "Do not emit outputs if any type checking errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: 2, key: "Do not emit comments to output." }, - Do_not_emit_outputs: { code: 6010, category: 2, key: "Do not emit outputs." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: 2, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: 2, key: "Specify module code generation: 'commonjs' or 'amd'" }, - Print_this_message: { code: 6017, category: 2, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: 2, key: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: 2, key: "Compile the project in the given directory." }, - Syntax_Colon_0: { code: 6023, category: 2, key: "Syntax: {0}" }, - options: { code: 6024, category: 2, key: "options" }, - file: { code: 6025, category: 2, key: "file" }, - Examples_Colon_0: { code: 6026, category: 2, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: 2, key: "Options:" }, - Version_0: { code: 6029, category: 2, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: 2, key: "Insert command line options and files from a file." }, - File_change_detected_Starting_incremental_compilation: { code: 6032, category: 2, key: "File change detected. Starting incremental compilation..." }, - KIND: { code: 6034, category: 2, key: "KIND" }, - FILE: { code: 6035, category: 2, key: "FILE" }, - VERSION: { code: 6036, category: 2, key: "VERSION" }, - LOCATION: { code: 6037, category: 2, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: 2, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: 2, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: 2, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: 1, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: 1, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: 1, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: 1, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: 1, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: 1, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: 1, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: 1, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2, key: "Raise error on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: 1, key: "File '{0}' not found." }, - File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: 2, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: 2, key: "Preserve new-lines when emitting code." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: 1, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: 1, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: 1, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: 1, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: 1, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: 1, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: 1, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: 1, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: 1, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: 1, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: 1, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: 1, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: 1, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, - _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: 1, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: 1, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: 1, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - You_cannot_rename_this_element: { code: 8000, category: 1, key: "You cannot rename this element." }, - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: 1, key: "You cannot rename elements that are defined in the standard TypeScript library." }, - yield_expressions_are_not_currently_supported: { code: 9000, category: 1, key: "'yield' expressions are not currently supported." }, - Generators_are_not_currently_supported: { code: 9001, category: 1, key: "Generators are not currently supported." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: 1, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." } + Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated string literal." }, + Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier expected." }, + _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, + Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing comma not allowed." }, + Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "'*/' expected." }, + Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected token." }, + A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, + Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, + A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, + An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, + An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, + An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, + An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, + An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, + An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, + An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, + A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, + A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: ts.DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, + Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, + _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, + _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, + _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, + An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: ts.DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, + super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, + Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, + Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, + Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, + A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, + A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, + A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, + A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, + A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, + A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, + An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." }, + Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, + A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, + _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, + _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, + Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, + Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, + An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, + A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, + An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, + _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, + Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, + Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, + with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, + delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, + Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, + A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, + Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression expected." }, + Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type expected." }, + A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, + An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, + Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, + A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, + Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, + Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit expected." }, + Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, + Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected end of text." }, + Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid character." }, + Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration or statement expected." }, + Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement expected." }, + case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, + Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, + Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, + Type_reference_expected: { code: 1133, category: ts.DiagnosticCategory.Error, key: "Type reference expected." }, + Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, + Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, + Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, + Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression or comma expected." }, + Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter declaration expected." }, + Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type parameter declaration expected." }, + Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type argument expected." }, + String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String literal expected." }, + Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line break not permitted here." }, + or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, + Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, + Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." }, + Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." }, + File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, + let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: ts.DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, + const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: ts.DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, + const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, + let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, + Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated template literal." }, + Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, + yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: ts.DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, + A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: ts.DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, + A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, + Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, + Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, + A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, + A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, + An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, + External_module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "External module '{0}' has no default export." }, + An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, + Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, + Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, + Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, + Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, + Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, + A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: ts.DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, + Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, + Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, + Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, + Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, + Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, + Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, + File_0_is_not_an_external_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not an external module." }, + Cannot_find_external_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find external module '{0}'." }, + A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, + Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, + A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, + An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An interface may only extend a class or another interface." }, + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, + Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic type '{0}' requires {1} type argument(s)." }, + Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not generic." }, + Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." }, + Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." }, + Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot find global type '{0}'." }, + Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, + Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, + Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, + Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, + Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, + Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, + Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, + Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, + Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, + Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, + Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, + this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, + this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, + this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, + this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, + super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, + super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, + Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, + Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, + Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot invoke an expression whose type lacks a call signature." }, + Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, + Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, + Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, + Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, + A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, + A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A parameter initializer is only allowed in a function or constructor implementation." }, + Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' cannot be referenced in its initializer." }, + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, + Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate string index signature." }, + Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate number index signature." }, + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, + Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, + A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, + get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, + A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, + Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, + Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, + Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, + Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function overload must be static." }, + Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function overload must not be static." }, + Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." }, + Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor implementation is missing." }, + Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." }, + Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, + Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, + Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, + Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." }, + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, + Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, + All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, + Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, + Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, + Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, + Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, + Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, + Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, + Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly implements interface '{1}'." }, + A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A class may only implement another class or interface." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, + Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface name cannot be '{0}'" }, + All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." }, + Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, + Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, + A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, + A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient external modules cannot be nested in other modules." }, + Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, + Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, + Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, + Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, + Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." }, + Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." }, + An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." }, + The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, + Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, + Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, + An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, + A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, + this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." }, + super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, + Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, + The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, + Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, + A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, + Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, + Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, + The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, + The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, + Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, + Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, + The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." }, + External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, + Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, + Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, + Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, + Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, + Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, + Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, + The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, + Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, + Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, + Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, + Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, + Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, + Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, + Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, + Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch input files." }, + Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, + Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any type checking errors were reported." }, + Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, + Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, + Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, + Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, + Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, + Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, + Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax: {0}" }, + options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options" }, + file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file" }, + Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples: {0}" }, + Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options:" }, + Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version {0}" }, + Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, + File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, + KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND" }, + FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE" }, + VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION" }, + LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION" }, + DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY" }, + Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, + Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, + Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, + Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, + Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, + Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, + Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, + Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, + Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, + File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File '{0}' not found." }, + File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, + Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, + Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, + Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, + Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, + Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index signature of object type implicitly has an 'any' type." }, + Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, + Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, + _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, + _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, + You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, + yield_expressions_are_not_currently_supported: { code: 9000, category: ts.DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, + Generators_are_not_currently_supported: { code: 9001, category: ts.DiagnosticCategory.Error, key: "Generators are not currently supported." } }; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { var textToToken = { - "any": 111, - "as": 101, - "boolean": 112, - "break": 65, - "case": 66, - "catch": 67, - "class": 68, - "continue": 70, - "const": 69, - "constructor": 113, - "debugger": 71, - "declare": 114, - "default": 72, - "delete": 73, - "do": 74, - "else": 75, - "enum": 76, - "export": 77, - "extends": 78, - "false": 79, - "finally": 80, - "for": 81, - "from": 123, - "function": 82, - "get": 115, - "if": 83, - "implements": 102, - "import": 84, - "in": 85, - "instanceof": 86, - "interface": 103, - "let": 104, - "module": 116, - "new": 87, - "null": 88, - "number": 118, - "package": 105, - "private": 106, - "protected": 107, - "public": 108, - "require": 117, - "return": 89, - "set": 119, - "static": 109, - "string": 120, - "super": 90, - "switch": 91, - "symbol": 121, - "this": 92, - "throw": 93, - "true": 94, - "try": 95, - "type": 122, - "typeof": 96, - "var": 97, - "void": 98, - "while": 99, - "with": 100, - "yield": 110, - "of": 124, + "any": 112, + "as": 102, + "boolean": 113, + "break": 66, + "case": 67, + "catch": 68, + "class": 69, + "continue": 71, + "const": 70, + "constructor": 114, + "debugger": 72, + "declare": 115, + "default": 73, + "delete": 74, + "do": 75, + "else": 76, + "enum": 77, + "export": 78, + "extends": 79, + "false": 80, + "finally": 81, + "for": 82, + "from": 124, + "function": 83, + "get": 116, + "if": 84, + "implements": 103, + "import": 85, + "in": 86, + "instanceof": 87, + "interface": 104, + "let": 105, + "module": 117, + "new": 88, + "null": 89, + "number": 119, + "package": 106, + "private": 107, + "protected": 108, + "public": 109, + "require": 118, + "return": 90, + "set": 120, + "static": 110, + "string": 121, + "super": 91, + "switch": 92, + "symbol": 122, + "this": 93, + "throw": 94, + "true": 95, + "try": 96, + "type": 123, + "typeof": 97, + "var": 98, + "void": 99, + "while": 100, + "with": 101, + "yield": 111, + "of": 125, "{": 14, "}": 15, "(": 16, @@ -2054,18 +2102,19 @@ var ts; "||": 49, "?": 50, ":": 51, - "=": 52, - "+=": 53, - "-=": 54, - "*=": 55, - "/=": 56, - "%=": 57, - "<<=": 58, - ">>=": 59, - ">>>=": 60, - "&=": 61, - "|=": 62, - "^=": 63 + "=": 53, + "+=": 54, + "-=": 55, + "*=": 56, + "/=": 57, + "%=": 58, + "<<=": 59, + ">>=": 60, + ">>>=": 61, + "&=": 62, + "|=": 63, + "^=": 64, + "@": 52 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -2106,9 +2155,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var _name in source) { - if (source.hasOwnProperty(_name)) { - result[source[_name]] = _name; + for (var name_2 in source) { + if (source.hasOwnProperty(name_2)) { + result[source[name_2]] = name_2; } } return result; @@ -2118,6 +2167,10 @@ var ts; return tokenStrings[t]; } ts.tokenToString = tokenToString; + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; function computeLineStarts(text) { var result = new Array(); var pos = 0; @@ -2175,13 +2228,35 @@ var ts; ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { - return ch === 32 || ch === 9 || ch === 11 || ch === 12 || - ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 || - ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279; + return ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; } ts.isWhiteSpace = isWhiteSpace; function isLineBreak(ch) { - return ch === 10 || ch === 13 || ch === 8232 || ch === 8233 || ch === 133; + // ES5 7.3: + // The ECMAScript line terminator characters are listed in Table 3. + // Table 3 � Line Terminator Characters + // Code Unit Value Name Formal Name + // \u000A Line Feed + // \u000D Carriage Return + // \u2028 Line separator + // \u2029 Paragraph separator + // Only the characters in Table 3 are treated as line terminators. Other new line or line + // breaking characters are treated as white space but not as line terminators. + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; } ts.isLineBreak = isLineBreak; function isDigit(ch) { @@ -2284,8 +2359,8 @@ var ts; else { ts.Debug.assert(ch === 61); while (pos < len) { - var _ch = text.charCodeAt(pos); - if (_ch === 62 && isConflictMarkerTrivia(text, pos)) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -2300,8 +2375,9 @@ var ts; var ch = text.charCodeAt(pos); switch (ch) { case 13: - if (text.charCodeAt(pos + 1) === 10) + if (text.charCodeAt(pos + 1) === 10) { pos++; + } case 10: pos++; if (trailing) { @@ -2343,8 +2419,9 @@ var ts; } } if (collecting) { - if (!result) + if (!result) { result = []; + } result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine }); } continue; @@ -2683,14 +2760,14 @@ var ts; return result; } function getIdentifierToken() { - var _len = tokenValue.length; - if (_len >= 2 && _len <= 11) { + var len = tokenValue.length; + if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { return token = textToToken[tokenValue]; } } - return token = 64; + return token = 65; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2769,7 +2846,7 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 37; case 38: @@ -2777,7 +2854,7 @@ var ts; return pos += 2, token = 48; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } return pos++, token = 43; case 40: @@ -2786,7 +2863,7 @@ var ts; return pos++, token = 17; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; + return pos += 2, token = 56; } return pos++, token = 35; case 43: @@ -2794,7 +2871,7 @@ var ts; return pos += 2, token = 38; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 53; + return pos += 2, token = 54; } return pos++, token = 33; case 44: @@ -2804,7 +2881,7 @@ var ts; return pos += 2, token = 39; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 54; + return pos += 2, token = 55; } return pos++, token = 34; case 46: @@ -2836,13 +2913,13 @@ var ts; pos += 2; var commentClosed = false; while (pos < len) { - var _ch = text.charCodeAt(pos); - if (_ch === 42 && text.charCodeAt(pos + 1) === 47) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { pos += 2; commentClosed = true; break; } - if (isLineBreak(_ch)) { + if (isLineBreak(ch_2)) { precedingLineBreak = true; } pos++; @@ -2859,7 +2936,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 36; case 48: @@ -2875,22 +2952,22 @@ var ts; } else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; - var _value = scanBinaryOrOctalDigits(2); - if (_value < 0) { + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); - _value = 0; + value = 0; } - tokenValue = "" + _value; + tokenValue = "" + value; return token = 7; } else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; - var _value_1 = scanBinaryOrOctalDigits(8); - if (_value_1 < 0) { + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); - _value_1 = 0; + value = 0; } - tokenValue = "" + _value_1; + tokenValue = "" + value; return token = 7; } if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { @@ -2924,7 +3001,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 58; + return pos += 3, token = 59; } return pos += 2, token = 40; } @@ -2951,7 +3028,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 32; } - return pos++, token = 52; + return pos++, token = 53; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2971,7 +3048,7 @@ var ts; return pos++, token = 19; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } return pos++, token = 45; case 123: @@ -2981,13 +3058,15 @@ var ts; return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } return pos++, token = 44; case 125: return pos++, token = 15; case 126: return pos++, token = 47; + case 64: + return pos++, token = 52; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3027,12 +3106,12 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } return pos++, token = 41; } @@ -3043,7 +3122,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 36 || token === 56) { + if (token === 36 || token === 57) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3137,8 +3216,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 64 || token > 100; }, - isReservedWord: function () { return token >= 65 && token <= 100; }, + isIdentifier: function () { return token === 65 || token > 101; }, + isReservedWord: function () { return token >= 66 && token <= 101; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3152,6 +3231,515 @@ var ts; } ts.createScanner = createScanner; })(ts || (ts = {})); +/// +var ts; +(function (ts) { + ts.bindTime = 0; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; + function getModuleInstanceState(node) { + if (node.kind === 199 || node.kind === 200) { + return 0; + } + else if (ts.isConstEnumDeclaration(node)) { + return 2; + } + else if ((node.kind === 206 || node.kind === 205) && !(node.flags & 1)) { + return 0; + } + else if (node.kind === 203) { + var state = 0; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0: + return false; + case 2: + state = 2; + return false; + case 1: + state = 1; + return true; + } + }); + return state; + } + else if (node.kind === 202) { + return getModuleInstanceState(node.body); + } + else { + return 1; + } + } + ts.getModuleInstanceState = getModuleInstanceState; + function bindSourceFile(file) { + var start = new Date().getTime(); + bindSourceFileWorker(file); + ts.bindTime += new Date().getTime() - start; + } + ts.bindSourceFile = bindSourceFile; + function bindSourceFileWorker(file) { + var parent; + var container; + var blockScopeContainer; + var lastContainer; + var symbolCount = 0; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + file.locals = {}; + container = file; + setBlockScopeContainer(file, false); + bind(file); + file.symbolCount = symbolCount; + } + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function setBlockScopeContainer(node, cleanLocals) { + blockScopeContainer = node; + if (cleanLocals) { + blockScopeContainer.locals = undefined; + } + } + function addDeclarationToSymbol(symbol, node, symbolKind) { + symbol.flags |= symbolKind; + if (!symbol.declarations) + symbol.declarations = []; + symbol.declarations.push(node); + if (symbolKind & 1952 && !symbol.exports) + symbol.exports = {}; + if (symbolKind & 6240 && !symbol.members) + symbol.members = {}; + node.symbol = symbol; + if (symbolKind & 107455 && !symbol.valueDeclaration) + symbol.valueDeclaration = node; + } + function getDeclarationName(node) { + if (node.name) { + if (node.kind === 202 && node.name.kind === 8) { + return '"' + node.name.text + '"'; + } + if (node.name.kind === 127) { + var nameExpression = node.name.expression; + ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); + return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); + } + return node.name.text; + } + switch (node.kind) { + case 143: + case 135: + return "__constructor"; + case 142: + case 138: + return "__call"; + case 139: + return "__new"; + case 140: + return "__index"; + case 212: + return "__export"; + case 211: + return node.isExportEquals ? "export=" : "default"; + case 197: + case 198: + return node.flags & 256 ? "default" : undefined; + } + } + function getDisplayName(node) { + return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); + } + function declareSymbol(symbols, parent, node, includes, excludes) { + ts.Debug.assert(!ts.hasDynamicName(node)); + var name = node.flags & 256 && parent ? "default" : getDeclarationName(node); + var symbol; + if (name !== undefined) { + symbol = ts.hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); + if (symbol.flags & excludes) { + if (node.name) { + node.name.parent = node; + } + var message = symbol.flags & 2 + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + symbol = createSymbol(0, name); + } + } + else { + symbol = createSymbol(0, "__missing"); + } + addDeclarationToSymbol(symbol, node, includes); + symbol.parent = parent; + if (node.kind === 198 && symbol.exports) { + var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); + if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; + } + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; + } + return symbol; + } + function declareModuleMember(node, symbolKind, symbolExcludes) { + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + if (symbolKind & 8388608) { + if (node.kind === 214 || (node.kind === 205 && hasExportModifier)) { + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + } + else { + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + } + } + else { + if (hasExportModifier || container.flags & 32768) { + var exportKind = (symbolKind & 107455 ? 1048576 : 0) | + (symbolKind & 793056 ? 2097152 : 0) | + (symbolKind & 1536 ? 4194304 : 0); + var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); + local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + node.localSymbol = local; + } + else { + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + } + } + } + function bindChildren(node, symbolKind, isBlockScopeContainer) { + if (symbolKind & 255504) { + node.locals = {}; + } + var saveParent = parent; + var saveContainer = container; + var savedBlockScopeContainer = blockScopeContainer; + parent = node; + if (symbolKind & 262128) { + container = node; + if (lastContainer) { + lastContainer.nextContainer = container; + } + lastContainer = container; + } + if (isBlockScopeContainer) { + setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 224); + } + ts.forEachChild(node, bind); + container = saveContainer; + parent = saveParent; + blockScopeContainer = savedBlockScopeContainer; + } + function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { + switch (container.kind) { + case 202: + declareModuleMember(node, symbolKind, symbolExcludes); + break; + case 224: + if (ts.isExternalModule(container)) { + declareModuleMember(node, symbolKind, symbolExcludes); + break; + } + case 142: + case 143: + case 138: + case 139: + case 140: + case 134: + case 133: + case 135: + case 136: + case 137: + case 197: + case 162: + case 163: + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + break; + case 198: + if (node.flags & 128) { + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + break; + } + case 145: + case 154: + case 199: + declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); + break; + case 201: + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + break; + } + bindChildren(node, symbolKind, isBlockScopeContainer); + } + function isAmbientContext(node) { + while (node) { + if (node.flags & 2) + return true; + node = node.parent; + } + return false; + } + function hasExportDeclarations(node) { + var body = node.kind === 224 ? node : node.body; + if (body.kind === 224 || body.kind === 203) { + for (var _i = 0, _a = body.statements, _n = _a.length; _i < _n; _i++) { + var stat = _a[_i]; + if (stat.kind === 212 || stat.kind === 211) { + return true; + } + } + } + return false; + } + function setExportContextFlag(node) { + if (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 32768; + } + else { + node.flags &= ~32768; + } + } + function bindModuleDeclaration(node) { + setExportContextFlag(node); + if (node.name.kind === 8) { + bindDeclaration(node, 512, 106639, true); + } + else { + var state = getModuleInstanceState(node); + if (state === 0) { + bindDeclaration(node, 1024, 0, true); + } + else { + bindDeclaration(node, 512, 106639, true); + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } + } + } + } + function bindFunctionOrConstructorType(node) { + // For a given function symbol "<...>(...) => T" we want to generate a symbol identical + // to the one we would get for: { <...>(...): T } + // + // We do that by making an anonymous type literal symbol, and then setting the function + // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable + // from an actual type literal symbol you would have gotten had you used the long form. + var symbol = createSymbol(131072, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072); + bindChildren(node, 131072, false); + var typeLiteralSymbol = createSymbol(2048, "__type"); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048); + typeLiteralSymbol.members = {}; + typeLiteralSymbol.members[node.kind === 142 ? "__call" : "__new"] = symbol; + } + function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { + var symbol = createSymbol(symbolKind, name); + addDeclarationToSymbol(symbol, node, symbolKind); + bindChildren(node, symbolKind, isBlockScopeContainer); + } + function bindCatchVariableDeclaration(node) { + bindChildren(node, 0, true); + } + function bindBlockScopedVariableDeclaration(node) { + switch (blockScopeContainer.kind) { + case 202: + declareModuleMember(node, 2, 107455); + break; + case 224: + if (ts.isExternalModule(container)) { + declareModuleMember(node, 2, 107455); + break; + } + default: + if (!blockScopeContainer.locals) { + blockScopeContainer.locals = {}; + } + declareSymbol(blockScopeContainer.locals, undefined, node, 2, 107455); + } + bindChildren(node, 2, false); + } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } + function bind(node) { + node.parent = parent; + switch (node.kind) { + case 128: + bindDeclaration(node, 262144, 530912, false); + break; + case 129: + bindParameter(node); + break; + case 195: + case 152: + if (ts.isBindingPattern(node.name)) { + bindChildren(node, 0, false); + } + else if (ts.isBlockOrCatchScoped(node)) { + bindBlockScopedVariableDeclaration(node); + } + else { + bindDeclaration(node, 1, 107454, false); + } + break; + case 132: + case 131: + bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); + break; + case 221: + case 222: + bindPropertyOrMethodOrAccessor(node, 4, 107455, false); + break; + case 223: + bindPropertyOrMethodOrAccessor(node, 8, 107455, false); + break; + case 138: + case 139: + case 140: + bindDeclaration(node, 131072, 0, false); + break; + case 134: + case 133: + bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); + break; + case 197: + bindDeclaration(node, 16, 106927, true); + break; + case 135: + bindDeclaration(node, 16384, 0, true); + break; + case 136: + bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); + break; + case 137: + bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); + break; + case 142: + case 143: + bindFunctionOrConstructorType(node); + break; + case 145: + bindAnonymousDeclaration(node, 2048, "__type", false); + break; + case 154: + bindAnonymousDeclaration(node, 4096, "__object", false); + break; + case 162: + case 163: + bindAnonymousDeclaration(node, 16, "__function", true); + break; + case 220: + bindCatchVariableDeclaration(node); + break; + case 198: + bindDeclaration(node, 32, 899583, false); + break; + case 199: + bindDeclaration(node, 64, 792992, false); + break; + case 200: + bindDeclaration(node, 524288, 793056, false); + break; + case 201: + if (ts.isConst(node)) { + bindDeclaration(node, 128, 899967, false); + } + else { + bindDeclaration(node, 256, 899327, false); + } + break; + case 202: + bindModuleDeclaration(node); + break; + case 205: + case 208: + case 210: + case 214: + bindDeclaration(node, 8388608, 8388608, false); + break; + case 207: + if (node.name) { + bindDeclaration(node, 8388608, 8388608, false); + } + else { + bindChildren(node, 0, false); + } + break; + case 212: + if (!node.exportClause) { + declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + } + bindChildren(node, 0, false); + break; + case 211: + if (node.expression && node.expression.kind === 65) { + declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); + } + else { + declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608); + } + bindChildren(node, 0, false); + break; + case 224: + setExportContextFlag(node); + if (ts.isExternalModule(node)) { + bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); + break; + } + case 176: + bindChildren(node, 0, !ts.isFunctionLike(node.parent)); + break; + case 220: + case 183: + case 184: + case 185: + case 204: + bindChildren(node, 0, true); + break; + default: + var saveParent = parent; + parent = node; + ts.forEachChild(node, bind); + parent = saveParent; + } + } + function bindParameter(node) { + if (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node), false); + } + else { + bindDeclaration(node, 1, 107455, false); + } + if (node.flags & 112 && + node.parent.kind === 135 && + node.parent.parent.kind === 198) { + var classDeclaration = node.parent.parent; + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); + } + } + function bindPropertyOrMethodOrAccessor(node, symbolKind, symbolExcludes, isBlockScopeContainer) { + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer); + } + else { + bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer); + } + } + } +})(ts || (ts = {})); +/// var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { @@ -3200,21 +3788,21 @@ var ts; ts.getFullWidth = getFullWidth; function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 32) !== 0; + return (node.parserContextFlags & 64) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 64)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || + if (!(node.parserContextFlags & 128)) { + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 32) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 32; + node.parserContextFlags |= 64; } - node.parserContextFlags |= 64; + node.parserContextFlags |= 128; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 221) { + while (node && node.kind !== 224) { node = node.parent; } return node; @@ -3296,15 +3884,15 @@ var ts; return current; } switch (current.kind) { - case 221: + case 224: + case 204: + case 220: case 202: - case 217: - case 200: - case 181: - case 182: case 183: + case 184: + case 185: return current; - case 174: + case 176: if (!isFunctionLike(current.parent)) { return current; } @@ -3315,9 +3903,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 193 && + declaration.kind === 195 && declaration.parent && - declaration.parent.kind === 217; + declaration.parent.kind === 220; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3354,15 +3942,15 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 193: - case 150: - case 196: - case 197: - case 200: - case 199: - case 220: case 195: - case 160: + case 152: + case 198: + case 199: + case 202: + case 201: + case 223: + case 197: + case 162: errorNode = node.name; break; } @@ -3384,11 +3972,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 199 && isConst(node); + return node.kind === 201 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 150 || isBindingPattern(node))) { + while (node && (node.kind === 152 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3396,14 +3984,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 193) { + if (node.kind === 195) { node = node.parent; } - if (node && node.kind === 194) { + if (node && node.kind === 196) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 175) { + if (node && node.kind === 177) { flags |= node.flags; } return flags; @@ -3418,12 +4006,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 177 && node.expression.kind === 8; + return node.kind === 179 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 128 || node.kind === 127) { + if (node.kind === 129 || node.kind === 128) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3445,23 +4032,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 186: + case 188: return visitor(node); - case 202: - case 174: - case 178: - case 179: + case 204: + case 176: case 180: case 181: case 182: case 183: - case 187: - case 188: - case 214: - case 215: + case 184: + case 185: case 189: - case 191: + case 190: case 217: + case 218: + case 191: + case 193: + case 220: return ts.forEachChild(node, traverse); } } @@ -3470,14 +4057,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 150: - case 220: - case 128: - case 218: - case 130: + case 152: + case 223: case 129: - case 219: - case 193: + case 221: + case 132: + case 131: + case 222: + case 195: return true; } } @@ -3487,22 +4074,22 @@ var ts; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 133: - case 160: - case 195: - case 161: - case 132: - case 131: - case 134: case 135: + case 162: + case 197: + case 163: + case 134: + case 133: case 136: case 137: case 138: + case 139: case 140: - case 141: - case 160: - case 161: - case 195: + case 142: + case 143: + case 162: + case 163: + case 197: return true; } } @@ -3510,11 +4097,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 174 && isFunctionLike(node.parent); + return node && node.kind === 176 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 132 && node.parent.kind === 152; + return node && node.kind === 134 && node.parent.kind === 154; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3533,28 +4120,28 @@ var ts; return undefined; } switch (node.kind) { - case 126: - if (node.parent.parent.kind === 196) { + case 127: + if (node.parent.parent.kind === 198) { return node; } node = node.parent; break; - case 161: + case 163: if (!includeArrowFunctions) { continue; } - case 195: - case 160: - case 200: - case 130: - case 129: + case 197: + case 162: + case 202: case 132: case 131: - case 133: case 134: + case 133: case 135: - case 199: - case 221: + case 136: + case 137: + case 201: + case 224: return node; } } @@ -3566,47 +4153,104 @@ var ts; if (!node) return node; switch (node.kind) { - case 126: - if (node.parent.parent.kind === 196) { + case 127: + if (node.parent.parent.kind === 198) { return node; } node = node.parent; break; - case 195: - case 160: - case 161: + case 197: + case 162: + case 163: if (!includeFunctions) { continue; } - case 130: - case 129: case 132: case 131: - case 133: case 134: + case 133: case 135: + case 136: + case 137: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 157) { + if (node.kind === 159) { return node.tag; } return node.expression; } ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 198: + return true; + case 132: + return node.parent.kind === 198; + case 129: + return node.parent.body && node.parent.parent.kind === 198; + case 136: + case 137: + case 134: + return node.body && node.parent.kind === 198; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + switch (node.kind) { + case 198: + if (node.decorators) { + return true; + } + return false; + case 132: + case 129: + if (node.decorators) { + return true; + } + return false; + case 136: + if (node.body && node.decorators) { + return true; + } + return false; + case 134: + case 137: + if (node.body && node.decorators) { + return true; + } + return false; + } + return false; + } + ts.nodeIsDecorated = nodeIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 198: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 134: + case 137: + return ts.forEach(node.parameters, nodeIsDecorated); + } + return false; + } + ts.childIsDecorated = childIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: case 9: - case 151: - case 152: case 153: case 154: case 155: @@ -3616,68 +4260,70 @@ var ts; case 159: case 160: case 161: - case 164: case 162: case 163: - case 165: case 166: + case 164: + case 165: case 167: case 168: - case 171: case 169: + case 170: + case 173: + case 171: case 10: - case 172: + case 174: return true; - case 125: - while (node.parent.kind === 125) { + case 126: + while (node.parent.kind === 126) { node = node.parent; } - return node.parent.kind === 142; - case 64: - if (node.parent.kind === 142) { + return node.parent.kind === 144; + case 65: + if (node.parent.kind === 144) { return true; } case 7: case 8: - var _parent = node.parent; - switch (_parent.kind) { - case 193: - case 128: - case 130: + var parent_1 = node.parent; + switch (parent_1.kind) { + case 195: case 129: - case 220: - case 218: - case 150: - return _parent.initializer === node; - case 177: - case 178: + case 132: + case 131: + case 223: + case 221: + case 152: + return parent_1.initializer === node; case 179: case 180: - case 186: - case 187: - case 188: - case 214: - case 190: - case 188: - return _parent.expression === node; case 181: - var forStatement = _parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 194) || + case 182: + case 188: + case 189: + case 190: + case 217: + case 192: + case 190: + return parent_1.expression === node; + case 183: + var forStatement = parent_1; + return (forStatement.initializer === node && forStatement.initializer.kind !== 196) || forStatement.condition === node || forStatement.iterator === node; - case 182: - case 183: - var forInStatement = _parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 194) || + case 184: + case 185: + var forInStatement = parent_1; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 196) || forInStatement.expression === node; - case 158: - return node === _parent.expression; - case 173: - return node === _parent.expression; - case 126: - return node === _parent.expression; + case 160: + return node === parent_1.expression; + case 175: + return node === parent_1.expression; + case 127: + return node === parent_1.expression; default: - if (isExpression(_parent)) { + if (isExpression(parent_1)) { return true; } } @@ -3692,7 +4338,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 203 && node.moduleReference.kind === 213; + return node.kind === 205 && node.moduleReference.kind === 216; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3701,41 +4347,41 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 203 && node.moduleReference.kind !== 213; + return node.kind === 205 && node.moduleReference.kind !== 216; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 204) { + if (node.kind === 206) { return node.moduleSpecifier; } - if (node.kind === 203) { + if (node.kind === 205) { var reference = node.moduleReference; - if (reference.kind === 213) { + if (reference.kind === 216) { return reference.expression; } } - if (node.kind === 210) { + if (node.kind === 212) { return node.moduleSpecifier; } } ts.getExternalModuleName = getExternalModuleName; function hasDotDotDotToken(node) { - return node && node.kind === 128 && node.dotDotDotToken !== undefined; + return node && node.kind === 129 && node.dotDotDotToken !== undefined; } ts.hasDotDotDotToken = hasDotDotDotToken; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 128: + case 129: return node.questionToken !== undefined; + case 134: + case 133: + return node.questionToken !== undefined; + case 222: + case 221: case 132: case 131: return node.questionToken !== undefined; - case 219: - case 218: - case 130: - case 129: - return node.questionToken !== undefined; } } return false; @@ -3758,7 +4404,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 149 || node.kind === 148); + return !!node && (node.kind === 151 || node.kind === 150); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -3773,33 +4419,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 161: - case 150: - case 196: - case 133: - case 199: - case 220: - case 212: - case 195: - case 160: - case 134: - case 205: - case 203: - case 208: + case 163: + case 152: + case 198: + case 135: + case 201: + case 223: + case 214: case 197: + case 162: + case 136: + case 207: + case 205: + case 210: + case 199: + case 134: + case 133: + case 202: + case 208: + case 129: + case 221: case 132: case 131: + case 137: + case 222: case 200: - case 206: case 128: - case 218: - case 130: - case 129: - case 135: - case 219: - case 198: - case 127: - case 193: + case 195: return true; } return false; @@ -3807,59 +4453,82 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 185: - case 184: - case 192: - case 179: - case 177: - case 176: - case 182: - case 183: - case 181: - case 178: - case 189: - case 186: - case 188: - case 93: - case 191: - case 175: - case 180: case 187: - case 209: + case 186: + case 194: + case 181: + case 179: + case 178: + case 184: + case 185: + case 183: + case 180: + case 191: + case 188: + case 190: + case 94: + case 193: + case 177: + case 182: + case 189: + case 211: return true; default: return false; } } ts.isStatement = isStatement; + function isClassElement(n) { + switch (n.kind) { + case 135: + case 132: + case 134: + case 136: + case 137: + case 140: + return true; + default: + return false; + } + } + ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 64 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 65 && name.kind !== 8 && name.kind !== 7) { return false; } - var _parent = name.parent; - if (_parent.kind === 208 || _parent.kind === 212) { - if (_parent.propertyName) { + var parent = name.parent; + if (parent.kind === 210 || parent.kind === 214) { + if (parent.propertyName) { return true; } } - if (isDeclaration(_parent)) { - return _parent.name === name; + if (isDeclaration(parent)) { + return parent.name === name; } return false; } ts.isDeclarationName = isDeclarationName; + function isAliasSymbolDeclaration(node) { + return node.kind === 205 || + node.kind === 207 && !!node.name || + node.kind === 208 || + node.kind === 210 || + node.kind === 214 || + node.kind === 211 && node.expression.kind === 65; + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassBaseTypeNode(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 78); + var heritageClause = getHeritageClause(node.heritageClauses, 79); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassBaseTypeNode = getClassBaseTypeNode; function getClassImplementedTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 102); + var heritageClause = getHeritageClause(node.heritageClauses, 103); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 78); + var heritageClause = getHeritageClause(node.heritageClauses, 79); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -3928,7 +4597,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 65 <= token && token <= 124; + return 66 <= token && token <= 125; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -3937,19 +4606,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 126 && + declaration.name.kind === 127 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 153 && isESSymbolIdentifier(node.expression); + return node.kind === 155 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 64 || name.kind === 8 || name.kind === 7) { + if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 126) { + if (name.kind === 127) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -3964,19 +4633,19 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 64 && node.text === "Symbol"; + return node.kind === 65 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 108: - case 106: - case 107: case 109: - case 77: - case 114: - case 69: - case 72: + case 107: + case 108: + case 110: + case 78: + case 115: + case 70: + case 73: return true; } return false; @@ -4092,7 +4761,7 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 200 || n.kind === 221; + return isFunctionLike(n) || n.kind === 202 || n.kind === 224; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4107,26 +4776,6 @@ var ts; return node; } ts.createSynthesizedNode = createSynthesizedNode; - function generateUniqueName(baseName, isExistingName) { - if (baseName.charCodeAt(0) !== 95) { - baseName = "_" + baseName; - if (!isExistingName(baseName)) { - return baseName; - } - } - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var _name = baseName + i; - if (!isExistingName(_name)) { - return _name; - } - i++; - } - } - ts.generateUniqueName = generateUniqueName; function createDiagnosticCollection() { var nonFileDiagnostics = []; var fileDiagnostics = {}; @@ -4227,10 +4876,267 @@ var ts; s; } ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(sourceFile, node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; } + }; + } + ts.createTextWriter = createTextWriter; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 135 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function shouldEmitToOwnFile(sourceFile, compilerOptions) { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { + return true; + } + return false; + } + return false; + } + ts.shouldEmitToOwnFile = shouldEmitToOwnFile; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 136) { + getAccessor = accessor; + } + else if (accessor.kind === 137) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 136 || member.kind === 137) + && (member.flags & 128) === (accessor.flags & 128)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 136 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 137 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + emitLeadingSpace = true; + } + }); + } + ts.emitComments = emitComments; + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + var lineCount = ts.getLineStarts(currentSourceFile).length; + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + if (pos !== comment.pos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + if (currentLineText) { + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + } + ts.writeCommentRange = writeCommentRange; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { - var nodeConstructors = new Array(223); + var nodeConstructors = new Array(226); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -4268,249 +5174,268 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 125: + case 126: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 127: + case 128: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 128: - case 130: case 129: - case 218: - case 219: - case 193: - case 150: - return visitNodes(cbNodes, node.modifiers) || + case 132: + case 131: + case 221: + case 222: + case 195: + case 152: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 140: - case 141: - case 136: - case 137: + case 142: + case 143: case 138: - return visitNodes(cbNodes, node.modifiers) || + case 139: + case 140: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 132: - case 131: - case 133: case 134: + case 133: case 135: - case 160: - case 195: - case 161: - return visitNodes(cbNodes, node.modifiers) || + case 136: + case 137: + case 162: + case 197: + case 163: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 139: + case 141: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 142: - return visitNode(cbNode, node.exprName); - case 143: - return visitNodes(cbNodes, node.members); case 144: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 145: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 146: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.elementType); case 147: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.elementTypes); case 148: + return visitNodes(cbNodes, node.types); case 149: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 150: case 151: return visitNodes(cbNodes, node.elements); - case 152: - return visitNodes(cbNodes, node.properties); case 153: + return visitNodes(cbNodes, node.elements); + case 154: + return visitNodes(cbNodes, node.properties); + case 155: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 154: + case 156: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 155: - case 156: + case 157: + case 158: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 157: + case 159: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 158: + case 160: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 159: - return visitNode(cbNode, node.expression); - case 162: - return visitNode(cbNode, node.expression); - case 163: + case 161: return visitNode(cbNode, node.expression); case 164: return visitNode(cbNode, node.expression); case 165: + return visitNode(cbNode, node.expression); + case 166: + return visitNode(cbNode, node.expression); + case 167: return visitNode(cbNode, node.operand); - case 170: + case 172: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 166: + case 168: return visitNode(cbNode, node.operand); - case 167: + case 169: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 168: + case 170: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 171: + case 173: return visitNode(cbNode, node.expression); - case 174: - case 201: + case 176: + case 203: return visitNodes(cbNodes, node.statements); - case 221: + case 224: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 175: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 194: - return visitNodes(cbNodes, node.declarations); case 177: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 196: + return visitNodes(cbNodes, node.declarations); + case 179: return visitNode(cbNode, node.expression); - case 178: + case 180: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 179: + case 181: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 180: + case 182: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 181: + case 183: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.iterator) || visitNode(cbNode, node.statement); - case 182: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 183: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 184: - case 185: - return visitNode(cbNode, node.label); - case 186: - return visitNode(cbNode, node.expression); - case 187: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 185: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 186: + case 187: + return visitNode(cbNode, node.label); case 188: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 202: - return visitNodes(cbNodes, node.clauses); - case 214: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 215: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 189: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 190: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 204: + return visitNodes(cbNodes, node.clauses); + case 217: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 218: + return visitNodes(cbNodes, node.statements); case 191: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 192: + return visitNode(cbNode, node.expression); + case 193: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 217: + case 220: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 196: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 197: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); + case 130: + return visitNode(cbNode, node.expression); case 198: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 199: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 200: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 199: - return visitNodes(cbNodes, node.modifiers) || + case 201: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 220: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 200: - return visitNodes(cbNodes, node.modifiers) || + case 202: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 203: - return visitNodes(cbNodes, node.modifiers) || + case 205: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 204: - return visitNodes(cbNodes, node.modifiers) || + case 206: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 205: + case 207: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 206: + case 208: return visitNode(cbNode, node.name); - case 207: - case 211: + case 209: + case 213: return visitNodes(cbNodes, node.elements); - case 210: - return visitNodes(cbNodes, node.modifiers) || + case 212: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 208: - case 212: + case 210: + case 214: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 209: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 169: + case 211: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 171: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 173: + case 175: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 126: + case 127: return visitNode(cbNode, node.expression); - case 216: + case 219: return visitNodes(cbNodes, node.types); - case 213: + case 216: return visitNode(cbNode, node.expression); + case 215: + return visitNodes(cbNodes, node.decorators); } } ts.forEachChild = forEachChild; @@ -4573,29 +5498,33 @@ var ts; ; function modifierToFlag(token) { switch (token) { - case 109: return 128; - case 108: return 16; - case 107: return 64; - case 106: return 32; - case 77: return 1; - case 114: return 2; - case 69: return 8192; - case 72: return 256; + case 110: return 128; + case 109: return 16; + case 108: return 64; + case 107: return 32; + case 78: return 1; + case 115: return 2; + case 70: return 8192; + case 73: return 256; } return 0; } ts.modifierToFlag = modifierToFlag; function fixupParentReferences(sourceFile) { - var _parent = sourceFile; + // normally parent references are set during binding. However, for clients that only need + // a syntax tree, and no semantic features, then the binding process is an unnecessary + // overhead. This functions allows us to set all the parents, without all the expense of + // binding. + var parent = sourceFile; forEachChild(sourceFile, visitNode); return; function visitNode(n) { - if (n.parent !== _parent) { - n.parent = _parent; - var saveParent = _parent; - _parent = n; + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; forEachChild(n, visitNode); - _parent = saveParent; + parent = saveParent; } } } @@ -4603,7 +5532,7 @@ var ts; switch (node.kind) { case 8: case 7: - case 64: + case 65: return true; } return false; @@ -4813,7 +5742,7 @@ var ts; } ts.updateSourceFile = updateSourceFile; function isEvalOrArgumentsIdentifier(node) { - return node.kind === 64 && + return node.kind === 65 && (node.text === "eval" || node.text === "arguments"); } ts.isEvalOrArgumentsIdentifier = isEvalOrArgumentsIdentifier; @@ -4895,12 +5824,13 @@ var ts; ts.createSourceFile = createSourceFile; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } + var disallowInAndDecoratorContext = 2 | 16; var parsingContext = 0; var identifiers = {}; var identifierCount = 0; var nodeCount = 0; var token; - var sourceFile = createNode(221, 0); + var sourceFile = createNode(224, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -4946,6 +5876,19 @@ var ts; function setGeneratorParameterContext(val) { setContextFlag(val, 8); } + function setDecoratorContext(val) { + setContextFlag(val, 16); + } + function doOutsideOfContext(flags, func) { + var currentContextFlags = contextFlags & flags; + if (currentContextFlags) { + setContextFlag(false, currentContextFlags); + var result = func(); + setContextFlag(true, currentContextFlags); + return result; + } + return func(); + } function allowInAnd(func) { if (contextFlags & 2) { setDisallowInContext(false); @@ -4982,6 +5925,15 @@ var ts; } return func(); } + function doInDecoratorContext(func) { + if (contextFlags & 16) { + return func(); + } + setDecoratorContext(true); + var result = func(); + setDecoratorContext(false); + return result; + } function inYieldContext() { return (contextFlags & 4) !== 0; } @@ -4994,10 +5946,13 @@ var ts; function inDisallowInContext() { return (contextFlags & 2) !== 0; } + function inDecoratorContext() { + return (contextFlags & 16) !== 0; + } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); - var _length = scanner.getTextPos() - start; - parseErrorAtPosition(start, _length, message, arg0); + var length = scanner.getTextPos() - start; + parseErrorAtPosition(start, length, message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { var lastError = ts.lastOrUndefined(sourceFile.parseDiagnostics); @@ -5054,13 +6009,13 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 64) { + if (token === 65) { return true; } - if (token === 110 && inYieldContext()) { + if (token === 111 && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 110 : token > 100; + return inStrictModeContext() ? token > 111 : token > 101; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -5131,7 +6086,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16; + node.parserContextFlags |= 32; } return node; } @@ -5153,12 +6108,12 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(64); + var node = createNode(65); node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(64, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(65, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -5181,7 +6136,7 @@ var ts; return parseIdentifierName(); } function parseComputedPropertyName() { - var node = createNode(126); + var node = createNode(127); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -5205,17 +6160,17 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); } function nextTokenCanFollowContextualModifier() { - if (token === 69) { - return nextToken() === 76; + if (token === 70) { + return nextToken() === 77; } - if (token === 77) { + if (token === 78) { nextToken(); - if (token === 72) { + if (token === 73) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 35 && token !== 14 && canFollowModifier(); } - if (token === 72) { + if (token === 73) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -5229,7 +6184,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 68 || token === 82; + return token === 69 || token === 83; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -5244,7 +6199,7 @@ var ts; case 4: return isStartOfStatement(inErrorRecovery); case 3: - return token === 66 || token === 72; + return token === 67 || token === 73; case 5: return isStartOfTypeMember(); case 6: @@ -5283,8 +6238,8 @@ var ts; return isIdentifier(); } function isNotHeritageClauseTypeName() { - if (token === 102 || - token === 78) { + if (token === 103 || + token === 79) { return lookAhead(nextTokenIsIdentifier); } return false; @@ -5305,13 +6260,13 @@ var ts; case 20: return token === 15; case 4: - return token === 15 || token === 66 || token === 72; + return token === 15 || token === 67 || token === 73; case 8: - return token === 14 || token === 78 || token === 102; + return token === 14 || token === 79 || token === 103; case 9: return isVariableDeclaratorListTerminator(); case 16: - return token === 25 || token === 16 || token === 14 || token === 78 || token === 102; + return token === 25 || token === 16 || token === 14 || token === 79 || token === 103; case 12: return token === 17 || token === 22; case 14: @@ -5404,7 +6359,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 31; + var nodeContextFlags = node.parserContextFlags & 63; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -5450,14 +6405,14 @@ var ts; function isReusableModuleElement(node) { if (node) { switch (node.kind) { - case 204: - case 203: - case 210: - case 209: - case 196: - case 197: - case 200: + case 206: + case 205: + case 212: + case 211: + case 198: case 199: + case 202: + case 201: return true; } return isReusableStatement(node); @@ -5467,12 +6422,12 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 133: - case 138: - case 132: - case 134: case 135: - case 130: + case 140: + case 134: + case 136: + case 137: + case 132: return true; } } @@ -5481,8 +6436,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 214: - case 215: + case 217: + case 218: return true; } } @@ -5491,56 +6446,56 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 195: - case 175: - case 174: - case 178: + case 197: case 177: - case 190: - case 186: - case 188: - case 185: - case 184: - case 182: - case 183: - case 181: - case 180: - case 187: case 176: - case 191: - case 189: + case 180: case 179: case 192: + case 188: + case 190: + case 187: + case 186: + case 184: + case 185: + case 183: + case 182: + case 189: + case 178: + case 193: + case 191: + case 181: + case 194: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 220; + return node.kind === 223; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 137: + case 139: + case 133: + case 140: case 131: case 138: - case 129: - case 136: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 193) { + if (node.kind !== 195) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 128) { + if (node.kind !== 129) { return false; } var parameter = node; @@ -5609,7 +6564,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(125, entity.pos); + var node = createNode(126, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -5620,13 +6575,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(64, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(169); + var template = createNode(171); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -5639,7 +6594,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(173); + var span = createNode(175); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -5673,7 +6628,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(139); + var node = createNode(141); node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 24) { node.typeArguments = parseBracketedList(17, parseType, 24, 25); @@ -5681,15 +6636,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(142); - parseExpected(96); + var node = createNode(144); + parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(127); + var node = createNode(128); node.name = parseIdentifier(); - if (parseOptional(78)) { + if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -5713,7 +6668,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token); + return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 52; } function setModifiers(node, modifiers) { if (modifiers) { @@ -5722,7 +6677,8 @@ var ts; } } function parseParameter() { - var node = createNode(128); + var node = createNode(129); + node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); @@ -5773,8 +6729,8 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 137) { - parseExpected(87); + if (kind === 139) { + parseExpected(88); } fillSignature(51, false, false, node); parseTypeMemberSemicolon(); @@ -5812,9 +6768,9 @@ var ts; nextToken(); return token === 51 || token === 23 || token === 19; } - function parseIndexSignatureDeclaration(modifiers) { - var fullStart = modifiers ? modifiers.pos : scanner.getStartPos(); - var node = createNode(138, fullStart); + function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { + var node = createNode(140, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(15, parseParameter, 18, 19); node.type = parseTypeAnnotation(); @@ -5823,19 +6779,19 @@ var ts; } function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); - var _name = parsePropertyName(); + var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(131, fullStart); - method.name = _name; + var method = createNode(133, fullStart); + method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(129, fullStart); - property.name = _name; + var property = createNode(131, fullStart); + property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -5876,14 +6832,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(136); + return parseSignatureMember(138); case 18: return isIndexSignature() - ? parseIndexSignatureDeclaration(undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 87: + case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(137); + return parseSignatureMember(139); } case 8: case 7: @@ -5901,9 +6857,11 @@ var ts; } } function parseIndexSignatureWithModifiers() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); return isIndexSignature() - ? parseIndexSignatureDeclaration(modifiers) + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) : undefined; } function isStartOfConstructSignature() { @@ -5911,7 +6869,7 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(143); + var node = createNode(145); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -5927,12 +6885,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(145); + var node = createNode(147); node.elementTypes = parseBracketedList(18, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(147); + var node = createNode(149); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -5940,8 +6898,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 141) { - parseExpected(87); + if (kind === 143) { + parseExpected(88); } fillSignature(32, false, false, node); return finishNode(node); @@ -5952,16 +6910,16 @@ var ts; } function parseNonArrayType() { switch (token) { - case 111: - case 120: - case 118: case 112: case 121: + case 119: + case 113: + case 122: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); - case 98: + case 99: return parseTokenNode(); - case 96: + case 97: return parseTypeQuery(); case 14: return parseTypeLiteral(); @@ -5975,17 +6933,17 @@ var ts; } function isStartOfType() { switch (token) { - case 111: - case 120: - case 118: case 112: case 121: - case 98: - case 96: + case 119: + case 113: + case 122: + case 99: + case 97: case 14: case 18: case 24: - case 87: + case 88: return true; case 16: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -6001,7 +6959,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(144, type.pos); + var node = createNode(146, type.pos); node.elementType = type; type = finishNode(node); } @@ -6016,7 +6974,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(146, type.pos); + var node = createNode(148, type.pos); node.types = types; type = finishNode(node); } @@ -6036,7 +6994,7 @@ var ts; if (isIdentifier() || ts.isModifier(token)) { nextToken(); if (token === 51 || token === 23 || - token === 50 || token === 52 || + token === 50 || token === 53 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -6061,10 +7019,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(140); + return parseFunctionOrConstructorType(142); } - if (token === 87) { - return parseFunctionOrConstructorType(141); + if (token === 88) { + return parseFunctionOrConstructorType(143); } return parseUnionTypeOrHigher(); } @@ -6073,11 +7031,11 @@ var ts; } function isStartOfExpression() { switch (token) { - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: case 7: case 8: case 10: @@ -6085,22 +7043,22 @@ var ts; case 16: case 18: case 14: - case 82: - case 87: + case 83: + case 88: case 36: - case 56: + case 57: case 33: case 34: case 47: case 46: - case 73: - case 96: - case 98: + case 74: + case 97: + case 99: case 38: case 39: case 24: - case 64: - case 110: + case 65: + case 111: return true; default: if (isBinaryOperator()) { @@ -6110,26 +7068,45 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && token !== 82 && isStartOfExpression(); + return token !== 14 && token !== 83 && token !== 52 && isStartOfExpression(); } function parseExpression() { + // Expression[in]: + // AssignmentExpression[in] + // Expression[in] , AssignmentExpression[in] + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; while ((operatorToken = parseOptionalToken(23))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } + if (saveDecoratorContext) { + setDecoratorContext(true); + } return expr; } function parseInitializer(inParameter) { - if (token !== 52) { + if (token !== 53) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { return undefined; } } - parseExpected(52); + parseExpected(53); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { + // AssignmentExpression[in,yield]: + // 1) ConditionalExpression[?in,?yield] + // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] + // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] + // 4) ArrowFunctionExpression[?in,?yield] + // 5) [+Yield] YieldExpression[?In] + // + // Note: for ease of implementation we treat productions '2' and '3' as the same thing. + // (i.e. they're both BinaryExpressions with an assignment operator in it). if (isYieldExpression()) { return parseYieldExpression(); } @@ -6138,7 +7115,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 64 && token === 32) { + if (expr.kind === 65 && token === 32) { return parseSimpleArrowFunctionExpression(expr); } if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { @@ -6147,7 +7124,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 110) { + if (token === 111) { if (inYieldContext()) { return true; } @@ -6168,7 +7145,7 @@ var ts; (isIdentifier() || token === 14 || token === 18); } function parseYieldExpression() { - var node = createNode(170); + var node = createNode(172); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -6182,14 +7159,14 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(161, identifier.pos); - var parameter = createNode(128, identifier.pos); + var node = createNode(163, identifier.pos); + var parameter = createNode(129, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - parseExpected(32); + node.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(); return finishNode(node); } @@ -6204,12 +7181,11 @@ var ts; if (!arrowFunction) { return undefined; } - if (parseExpected(32) || token === 14) { - arrowFunction.body = parseArrowFunctionExpressionBody(); - } - else { - arrowFunction.body = parseIdentifier(); - } + var lastToken = token; + arrowFunction.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 32 || lastToken === 14) + ? parseArrowFunctionExpressionBody() + : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { @@ -6259,7 +7235,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(161); + var node = createNode(163); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -6273,7 +7249,7 @@ var ts; if (token === 14) { return parseFunctionBlock(false, false); } - if (isStartOfStatement(true) && !isStartOfExpressionStatement() && token !== 82) { + if (isStartOfStatement(true) && !isStartOfExpressionStatement() && token !== 83) { return parseFunctionBlock(false, true); } return parseAssignmentExpressionOrHigher(); @@ -6283,10 +7259,10 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(168, leftOperand.pos); + var node = createNode(170, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; - node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); node.colonToken = parseExpectedToken(51, false, ts.Diagnostics._0_expected, ts.tokenToString(51)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); @@ -6296,7 +7272,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 85 || t === 124; + return t === 86 || t === 125; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -6305,7 +7281,7 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 85 && inDisallowInContext()) { + if (token === 86 && inDisallowInContext()) { break; } leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); @@ -6313,7 +7289,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 85) { + if (inDisallowInContext() && token === 86) { return false; } return getBinaryOperatorPrecedence() > 0; @@ -6339,8 +7315,8 @@ var ts; case 25: case 26: case 27: + case 87: case 86: - case 85: return 7; case 40: case 41: @@ -6357,33 +7333,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(167, left.pos); + var node = createNode(169, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(165); + var node = createNode(167); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(162); + var node = createNode(164); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(163); + var node = createNode(165); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(164); + var node = createNode(166); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -6397,11 +7373,11 @@ var ts; case 38: case 39: return parsePrefixUnaryExpression(); - case 73: + case 74: return parseDeleteExpression(); - case 96: + case 97: return parseTypeOfExpression(); - case 98: + case 99: return parseVoidExpression(); case 24: return parseTypeAssertion(); @@ -6413,7 +7389,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(166, expression.pos); + var node = createNode(168, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -6422,7 +7398,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 90 + var expression = token === 91 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -6436,14 +7412,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(153, expression.pos); + var node = createNode(155, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(158); + var node = createNode(160); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -6454,15 +7430,15 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(153, expression.pos); + var propertyAccess = createNode(155, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (parseOptional(18)) { - var indexedAccess = createNode(154, expression.pos); + if (!inDecoratorContext() && parseOptional(18)) { + var indexedAccess = createNode(156, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -6476,7 +7452,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(157, expression.pos); + var tagExpression = createNode(159, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -6495,7 +7471,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(155, expression.pos); + var callExpr = createNode(157, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -6503,10 +7479,10 @@ var ts; continue; } else if (token === 16) { - var _callExpr = createNode(155, expression.pos); - _callExpr.expression = expression; - _callExpr.arguments = parseArgumentList(); - expression = finishNode(_callExpr); + var callExpr = createNode(157, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); continue; } return expression; @@ -6562,11 +7538,11 @@ var ts; case 8: case 10: return parseLiteralNode(); - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: return parseTokenNode(); case 16: return parseParenthesizedExpression(); @@ -6574,12 +7550,12 @@ var ts; return parseArrayLiteralExpression(); case 14: return parseObjectLiteralExpression(); - case 82: + case 83: return parseFunctionExpression(); - case 87: + case 88: return parseNewExpression(); case 36: - case 56: + case 57: if (reScanSlashToken() === 9) { return parseLiteralNode(); } @@ -6590,28 +7566,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(159); + var node = createNode(161); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(171); + var node = createNode(173); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(172) : + token === 23 ? createNode(174) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { - return allowInAnd(parseArgumentOrArrayLiteralElement); + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(151); + var node = createNode(153); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; @@ -6619,19 +7595,20 @@ var ts; parseExpected(19); return finishNode(node); } - function tryParseAccessorDeclaration(fullStart, modifiers) { - if (parseContextualModifier(115)) { - return parseAccessorDeclaration(134, fullStart, modifiers); + function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { + if (parseContextualModifier(116)) { + return parseAccessorDeclaration(136, fullStart, decorators, modifiers); } - else if (parseContextualModifier(119)) { - return parseAccessorDeclaration(135, fullStart, modifiers); + else if (parseContextualModifier(120)) { + return parseAccessorDeclaration(137, fullStart, decorators, modifiers); } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, modifiers); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } @@ -6641,16 +7618,16 @@ var ts; var propertyName = parsePropertyName(); var questionToken = parseOptionalToken(50); if (asteriskToken || token === 16 || token === 24) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, propertyName, questionToken); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(219, fullStart); + var shorthandDeclaration = createNode(222, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(218, fullStart); + var propertyAssignment = createNode(221, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -6659,7 +7636,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(152); + var node = createNode(154); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; @@ -6669,20 +7646,27 @@ var ts; return finishNode(node); } function parseFunctionExpression() { - var node = createNode(160); - parseExpected(82); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var node = createNode(162); + parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); fillSignature(51, !!node.asteriskToken, false, node); node.body = parseFunctionBlock(!!node.asteriskToken, false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } return finishNode(node); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(156); - parseExpected(87); + var node = createNode(158); + parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 16) { @@ -6691,7 +7675,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(174); + var node = createNode(176); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(2, checkForStrictMode, parseStatement); parseExpected(15); @@ -6704,30 +7688,37 @@ var ts; function parseFunctionBlock(allowYield, ignoreMissingOpenBrace, diagnosticMessage) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } setYieldContext(savedYieldContext); return block; } function parseEmptyStatement() { - var node = createNode(176); + var node = createNode(178); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(178); - parseExpected(83); + var node = createNode(180); + parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(75) ? parseStatement() : undefined; + node.elseStatement = parseOptional(76) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(179); - parseExpected(74); + var node = createNode(181); + parseExpected(75); node.statement = parseStatement(); - parseExpected(99); + parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6735,8 +7726,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(180); - parseExpected(99); + var node = createNode(182); + parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6745,11 +7736,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(81); + parseExpected(82); parseExpected(16); var initializer = undefined; if (token !== 22) { - if (token === 97 || token === 104 || token === 69) { + if (token === 98 || token === 105 || token === 70) { initializer = parseVariableDeclarationList(true); } else { @@ -6757,22 +7748,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(85)) { - var forInStatement = createNode(182, pos); + if (parseOptional(86)) { + var forInStatement = createNode(184, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(124)) { - var forOfStatement = createNode(183, pos); + else if (parseOptional(125)) { + var forOfStatement = createNode(185, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(181, pos); + var forStatement = createNode(183, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -6790,7 +7781,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 185 ? 65 : 70); + parseExpected(kind === 187 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -6798,8 +7789,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(186); - parseExpected(89); + var node = createNode(188); + parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -6807,8 +7798,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(187); - parseExpected(100); + var node = createNode(189); + parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6816,30 +7807,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(214); - parseExpected(66); + var node = createNode(217); + parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); node.statements = parseList(4, false, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(215); - parseExpected(72); + var node = createNode(218); + parseExpected(73); parseExpected(51); node.statements = parseList(4, false, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 66 ? parseCaseClause() : parseDefaultClause(); + return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(188); - parseExpected(91); + var node = createNode(190); + parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(202, scanner.getStartPos()); + var caseBlock = createNode(204, scanner.getStartPos()); parseExpected(14); caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); parseExpected(15); @@ -6847,26 +7838,28 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(190); - parseExpected(93); + // ThrowStatement[Yield] : + // throw [no LineTerminator here]Expression[In, ?Yield]; + var node = createNode(192); + parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(191); - parseExpected(95); + var node = createNode(193); + parseExpected(96); node.tryBlock = parseBlock(false, false); - node.catchClause = token === 67 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 80) { - parseExpected(80); + node.catchClause = token === 68 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 81) { + parseExpected(81); node.finallyBlock = parseBlock(false, false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(217); - parseExpected(67); + var result = createNode(220); + parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -6875,22 +7868,22 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(192); - parseExpected(71); + var node = createNode(194); + parseExpected(72); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 64 && parseOptional(51)) { - var labeledStatement = createNode(189, fullStart); + if (expression.kind === 65 && parseOptional(51)) { + var labeledStatement = createNode(191, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(177, fullStart); + var expressionStatement = createNode(179, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -6898,7 +7891,7 @@ var ts; } function isStartOfStatement(inErrorRecovery) { if (ts.isModifier(token)) { - var result = lookAhead(parseVariableStatementOrFunctionDeclarationWithModifiers); + var result = lookAhead(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return true; } @@ -6907,39 +7900,39 @@ var ts; case 22: return !inErrorRecovery; case 14: - case 97: - case 104: - case 82: + case 98: + case 105: case 83: - case 74: - case 99: - case 81: - case 70: - case 65: - case 89: + case 84: + case 75: case 100: - case 91: - case 93: - case 95: + case 82: case 71: - case 67: - case 80: + case 66: + case 90: + case 101: + case 92: + case 94: + case 96: + case 72: + case 68: + case 81: return true; - case 69: + case 70: var isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; - case 103: - case 68: - case 116: - case 76: - case 122: + case 104: + case 69: + case 117: + case 77: + case 123: if (isDeclarationStart()) { return false; } - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { return false; } @@ -6949,7 +7942,7 @@ var ts; } function nextTokenIsEnumKeyword() { nextToken(); - return token === 76; + return token === 77; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -6959,46 +7952,46 @@ var ts; switch (token) { case 14: return parseBlock(false, false); - case 97: - case 69: - return parseVariableStatement(scanner.getStartPos(), undefined); - case 82: - return parseFunctionDeclaration(scanner.getStartPos(), undefined); + case 98: + case 70: + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + case 83: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 22: return parseEmptyStatement(); - case 83: + case 84: return parseIfStatement(); - case 74: + case 75: return parseDoStatement(); - case 99: - return parseWhileStatement(); - case 81: - return parseForOrForInOrForOfStatement(); - case 70: - return parseBreakOrContinueStatement(184); - case 65: - return parseBreakOrContinueStatement(185); - case 89: - return parseReturnStatement(); case 100: - return parseWithStatement(); - case 91: - return parseSwitchStatement(); - case 93: - return parseThrowStatement(); - case 95: - case 67: - case 80: - return parseTryStatement(); + return parseWhileStatement(); + case 82: + return parseForOrForInOrForOfStatement(); case 71: + return parseBreakOrContinueStatement(186); + case 66: + return parseBreakOrContinueStatement(187); + case 90: + return parseReturnStatement(); + case 101: + return parseWithStatement(); + case 92: + return parseSwitchStatement(); + case 94: + return parseThrowStatement(); + case 96: + case 68: + case 81: + return parseTryStatement(); + case 72: return parseDebuggerStatement(); - case 104: + case 105: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined); + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } default: - if (ts.isModifier(token)) { - var result = tryParse(parseVariableStatementOrFunctionDeclarationWithModifiers); + if (ts.isModifier(token) || token === 52) { + var result = tryParse(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return result; } @@ -7006,25 +7999,26 @@ var ts; return parseExpressionOrLabeledStatement(); } } - function parseVariableStatementOrFunctionDeclarationWithModifiers() { + function parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers() { var start = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 69: + case 70: var nextTokenIsEnum = lookAhead(nextTokenIsEnumKeyword); if (nextTokenIsEnum) { return undefined; } - return parseVariableStatement(start, modifiers); - case 104: + return parseVariableStatement(start, decorators, modifiers); + case 105: if (!isLetDeclaration()) { return undefined; } - return parseVariableStatement(start, modifiers); - case 97: - return parseVariableStatement(start, modifiers); - case 82: - return parseFunctionDeclaration(start, modifiers); + return parseVariableStatement(start, decorators, modifiers); + case 98: + return parseVariableStatement(start, decorators, modifiers); + case 83: + return parseFunctionDeclaration(start, decorators, modifiers); } return undefined; } @@ -7037,18 +8031,18 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(172); + return createNode(174); } - var node = createNode(150); + var node = createNode(152); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(150); + var node = createNode(152); var id = parsePropertyName(); - if (id.kind === 64 && token !== 51) { + if (id.kind === 65 && token !== 51) { node.name = id; } else { @@ -7060,14 +8054,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(148); + var node = createNode(150); parseExpected(14); node.elements = parseDelimitedList(10, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(149); + var node = createNode(151); parseExpected(18); node.elements = parseDelimitedList(11, parseArrayBindingElement); parseExpected(19); @@ -7086,7 +8080,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(193); + var node = createNode(195); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7095,21 +8089,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(194); + var node = createNode(196); switch (token) { - case 97: + case 98: break; - case 104: + case 105: node.flags |= 4096; break; - case 69: + case 70: node.flags |= 8192; break; default: ts.Debug.fail(); } nextToken(); - if (token === 124 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 125 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -7123,33 +8117,37 @@ var ts; function canFollowContextualOfKeyword() { return nextTokenIsIdentifier() && nextToken() === 17; } - function parseVariableStatement(fullStart, modifiers) { - var node = createNode(175, fullStart); + function parseVariableStatement(fullStart, decorators, modifiers) { + var node = createNode(177, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } - function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(195, fullStart); + function parseFunctionDeclaration(fullStart, decorators, modifiers) { + var node = createNode(197, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(82); + parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); fillSignature(51, !!node.asteriskToken, false, node); node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, ts.Diagnostics.or_expected); return finishNode(node); } - function parseConstructorDeclaration(pos, modifiers) { - var node = createNode(133, pos); + function parseConstructorDeclaration(pos, decorators, modifiers) { + var node = createNode(135, pos); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(113); + parseExpected(114); fillSignature(51, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, ts.Diagnostics.or_expected); return finishNode(node); } - function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(132, fullStart); + function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { + var method = createNode(134, fullStart); + method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; @@ -7158,29 +8156,34 @@ var ts; method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); return finishNode(method); } - function parsePropertyOrMethodDeclaration(fullStart, modifiers) { + function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { + var property = createNode(132, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + property.initializer = allowInAnd(parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(35); - var _name = parsePropertyName(); + var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (asteriskToken || token === 16 || token === 24) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, _name, questionToken, ts.Diagnostics.or_expected); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { - var property = createNode(130, fullStart); - setModifiers(property, modifiers); - property.name = _name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); } } function parseNonParameterInitializer() { return parseInitializer(false); } - function parseAccessorDeclaration(kind, fullStart, modifiers) { + function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); fillSignature(51, false, false, node); @@ -7189,6 +8192,9 @@ var ts; } function isClassMemberStart() { var idToken; + if (token === 52) { + return true; + } while (ts.isModifier(token)) { idToken = token; nextToken(); @@ -7204,14 +8210,14 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 119 || idToken === 115) { + if (!ts.isKeyword(idToken) || idToken === 120 || idToken === 116) { return true; } switch (token) { case 16: case 24: case 51: - case 52: + case 53: case 50: return true; default: @@ -7220,6 +8226,26 @@ var ts; } return false; } + function parseDecorators() { + var decorators; + while (true) { + var decoratorStart = getNodePos(); + if (!parseOptional(52)) { + break; + } + if (!decorators) { + decorators = []; + decorators.pos = scanner.getStartPos(); + } + var decorator = createNode(130, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } function parseModifiers() { var flags = 0; var modifiers; @@ -7244,30 +8270,40 @@ var ts; } function parseClassElement() { var fullStart = getNodePos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, modifiers); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } - if (token === 113) { - return parseConstructorDeclaration(fullStart, modifiers); + if (token === 114) { + return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { - return parseIndexSignatureDeclaration(modifiers); + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } if (isIdentifierOrKeyword() || token === 8 || token === 7 || token === 35 || token === 18) { - return parsePropertyOrMethodDeclaration(fullStart, modifiers); + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + if (decorators) { + var name_3 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_3, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } - function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(196, fullStart); + function parseClassDeclaration(fullStart, decorators, modifiers) { + var savedStrictModeContext = inStrictModeContext(); + if (languageVersion >= 2) { + setStrictModeContext(true); + } + var node = createNode(198, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(68); + parseExpected(69); node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); @@ -7280,9 +8316,14 @@ var ts; else { node.members = createMissingList(); } - return finishNode(node); + var finishedNode = finishNode(node); + setStrictModeContext(savedStrictModeContext); + return finishedNode; } function parseHeritageClauses(isClassHeritageClause) { + // ClassTail[Yield,GeneratorParameter] : See 14.5 + // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } if (isHeritageClause()) { return isClassHeritageClause && inGeneratorParameterContext() ? doOutsideOfYieldContext(parseHeritageClausesWorker) @@ -7294,8 +8335,8 @@ var ts; return parseList(19, false, parseHeritageClause); } function parseHeritageClause() { - if (token === 78 || token === 102) { - var node = createNode(216); + if (token === 79 || token === 103) { + var node = createNode(219); node.token = token; nextToken(); node.types = parseDelimitedList(8, parseTypeReference); @@ -7304,41 +8345,44 @@ var ts; return undefined; } function isHeritageClause() { - return token === 78 || token === 102; + return token === 79 || token === 103; } function parseClassMembers() { return parseList(6, false, parseClassElement); } - function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(197, fullStart); + function parseInterfaceDeclaration(fullStart, decorators, modifiers) { + var node = createNode(199, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(103); + parseExpected(104); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); node.members = parseObjectTypeMembers(); return finishNode(node); } - function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(198, fullStart); + function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { + var node = createNode(200, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(122); + parseExpected(123); node.name = parseIdentifier(); - parseExpected(52); + parseExpected(53); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(220, scanner.getStartPos()); + var node = createNode(223, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } - function parseEnumDeclaration(fullStart, modifiers) { - var node = createNode(199, fullStart); + function parseEnumDeclaration(fullStart, decorators, modifiers) { + var node = createNode(201, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(76); + parseExpected(77); node.name = parseIdentifier(); if (parseExpected(14)) { node.members = parseDelimitedList(7, parseEnumMember); @@ -7350,7 +8394,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(201, scanner.getStartPos()); + var node = createNode(203, scanner.getStartPos()); if (parseExpected(14)) { node.statements = parseList(1, false, parseModuleElement); parseExpected(15); @@ -7360,31 +8404,33 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, modifiers, flags) { - var node = createNode(200, fullStart); + function parseInternalModuleTail(fullStart, decorators, modifiers, flags) { + var node = createNode(202, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(20) - ? parseInternalModuleTail(getNodePos(), undefined, 1) + ? parseInternalModuleTail(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { - var node = createNode(200, fullStart); + function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { + var node = createNode(202, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart, modifiers) { - parseExpected(116); + function parseModuleDeclaration(fullStart, decorators, modifiers) { + parseExpected(117); return token === 8 - ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) - : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) + : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); } function isExternalModuleReference() { - return token === 117 && + return token === 118 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -7393,44 +8439,52 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 123; + token === 124; } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers) { - parseExpected(84); + function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { + parseExpected(85); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 123) { - var importEqualsDeclaration = createNode(203, fullStart); + if (token !== 23 && token !== 124) { + var importEqualsDeclaration = createNode(205, fullStart); + importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(52); + parseExpected(53); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(204, fullStart); + var importDeclaration = createNode(206, fullStart); + importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(123); + parseExpected(124); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(205, fullStart); + //ImportClause: + // ImportedDefaultBinding + // NameSpaceImport + // NamedImports + // ImportedDefaultBinding, NameSpaceImport + // ImportedDefaultBinding, NamedImports + var importClause = createNode(207, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(207); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(209); } return finishNode(importClause); } @@ -7440,8 +8494,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(213); - parseExpected(117); + var node = createNode(216); + parseExpected(118); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -7455,107 +8509,116 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(206); + var namespaceImport = createNode(208); parseExpected(35); - parseExpected(101); + parseExpected(102); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 207 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(20, kind === 209 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(212); + return parseImportOrExportSpecifier(214); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(208); + return parseImportOrExportSpecifier(210); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); - var isFirstIdentifierNameNotAnIdentifier = ts.isKeyword(token) && !isIdentifier(); - var start = scanner.getTokenPos(); + var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + var checkIdentifierStart = scanner.getTokenPos(); + var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 101) { + if (token === 102) { node.propertyName = identifierName; - parseExpected(101); - if (isIdentifier()) { - node.name = parseIdentifierName(); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - } + parseExpected(102); + checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); } else { node.name = identifierName; - if (isFirstIdentifierNameNotAnIdentifier) { - parseErrorAtPosition(start, identifierName.end - start, ts.Diagnostics.Identifier_expected); - } + } + if (kind === 210 && checkIdentifierIsKeyword) { + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } - function parseExportDeclaration(fullStart, modifiers) { - var node = createNode(210, fullStart); + function parseExportDeclaration(fullStart, decorators, modifiers) { + var node = createNode(212, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(123); + parseExpected(124); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(211); - if (parseOptional(123)) { + node.exportClause = parseNamedImportsOrExports(213); + if (parseOptional(124)) { node.moduleSpecifier = parseModuleSpecifier(); } } parseSemicolon(); return finishNode(node); } - function parseExportAssignment(fullStart, modifiers) { - var node = createNode(209, fullStart); + function parseExportAssignment(fullStart, decorators, modifiers) { + var node = createNode(211, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(52)) { + if (parseOptional(53)) { node.isExportEquals = true; + node.expression = parseAssignmentExpressionOrHigher(); } else { - parseExpected(72); + parseExpected(73); + if (parseOptional(51)) { + node.type = parseType(); + } + else { + node.expression = parseAssignmentExpressionOrHigher(); + } } - node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function isLetDeclaration() { return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); } - function isDeclarationStart() { + function isDeclarationStart(followsModifier) { switch (token) { - case 97: - case 69: - case 82: + case 98: + case 70: + case 83: return true; - case 104: + case 105: return isLetDeclaration(); - case 68: - case 103: - case 76: - case 122: - return lookAhead(nextTokenIsIdentifierOrKeyword); - case 84: - return lookAhead(nextTokenCanFollowImportKeyword); - case 116: - return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 69: + case 104: case 77: + case 123: + return lookAhead(nextTokenIsIdentifierOrKeyword); + case 85: + return lookAhead(nextTokenCanFollowImportKeyword); + case 117: + return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 78: return lookAhead(nextTokenCanFollowExportKeyword); - case 114: - case 108: - case 106: - case 107: + case 115: case 109: + case 107: + case 108: + case 110: return lookAhead(nextTokenIsDeclarationStart); + case 52: + return !followsModifier; } } function isIdentifierOrKeyword() { - return token >= 64; + return token >= 65; } function nextTokenIsIdentifierOrKeyword() { nextToken(); @@ -7572,48 +8635,56 @@ var ts; } function nextTokenCanFollowExportKeyword() { nextToken(); - return token === 52 || token === 35 || - token === 14 || token === 72 || isDeclarationStart(); + return token === 53 || token === 35 || + token === 14 || token === 73 || isDeclarationStart(true); } function nextTokenIsDeclarationStart() { nextToken(); - return isDeclarationStart(); + return isDeclarationStart(true); } function nextTokenIsAsKeyword() { - return nextToken() === 101; + return nextToken() === 102; } function parseDeclaration() { var fullStart = getNodePos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (token === 77) { + if (token === 78) { nextToken(); - if (token === 72 || token === 52) { - return parseExportAssignment(fullStart, modifiers); + if (token === 73 || token === 53) { + return parseExportAssignment(fullStart, decorators, modifiers); } if (token === 35 || token === 14) { - return parseExportDeclaration(fullStart, modifiers); + return parseExportDeclaration(fullStart, decorators, modifiers); } } switch (token) { - case 97: - case 104: + case 98: + case 105: + case 70: + return parseVariableStatement(fullStart, decorators, modifiers); + case 83: + return parseFunctionDeclaration(fullStart, decorators, modifiers); case 69: - return parseVariableStatement(fullStart, modifiers); - case 82: - return parseFunctionDeclaration(fullStart, modifiers); - case 68: - return parseClassDeclaration(fullStart, modifiers); - case 103: - return parseInterfaceDeclaration(fullStart, modifiers); - case 122: - return parseTypeAliasDeclaration(fullStart, modifiers); - case 76: - return parseEnumDeclaration(fullStart, modifiers); - case 116: - return parseModuleDeclaration(fullStart, modifiers); - case 84: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers); + return parseClassDeclaration(fullStart, decorators, modifiers); + case 104: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 123: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 77: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 117: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 85: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); default: + if (decorators) { + var node = createMissingNode(215, true, ts.Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } } @@ -7688,10 +8759,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 203 && node.moduleReference.kind === 213 - || node.kind === 204 - || node.kind === 209 - || node.kind === 210 + || node.kind === 205 && node.moduleReference.kind === 216 + || node.kind === 206 + || node.kind === 211 + || node.kind === 212 ? node : undefined; }); @@ -7700,26 +8771,26 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 153: - case 154: - case 156: case 155: + case 156: + case 158: case 157: - case 151: case 159: - case 152: - case 160: - case 64: + case 153: + case 161: + case 154: + case 162: + case 65: case 9: case 7: case 8: case 10: - case 169: - case 79: - case 88: - case 92: - case 94: - case 90: + case 171: + case 80: + case 89: + case 93: + case 95: + case 91: return true; } } @@ -7727,494 +8798,30 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 52 && token <= 63; + return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; })(ts || (ts = {})); -var ts; -(function (ts) { - ts.bindTime = 0; - (function (ModuleInstanceState) { - ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; - ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; - ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; - })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - var ModuleInstanceState = ts.ModuleInstanceState; - function getModuleInstanceState(node) { - if (node.kind === 197 || node.kind === 198) { - return 0; - } - else if (ts.isConstEnumDeclaration(node)) { - return 2; - } - else if ((node.kind === 204 || node.kind === 203) && !(node.flags & 1)) { - return 0; - } - else if (node.kind === 201) { - var state = 0; - ts.forEachChild(node, function (n) { - switch (getModuleInstanceState(n)) { - case 0: - return false; - case 2: - state = 2; - return false; - case 1: - state = 1; - return true; - } - }); - return state; - } - else if (node.kind === 200) { - return getModuleInstanceState(node.body); - } - else { - return 1; - } - } - ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { - var start = new Date().getTime(); - bindSourceFileWorker(file); - ts.bindTime += new Date().getTime() - start; - } - ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { - var _parent; - var container; - var blockScopeContainer; - var lastContainer; - var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - if (!file.locals) { - file.locals = {}; - container = file; - setBlockScopeContainer(file, false); - bind(file); - file.symbolCount = symbolCount; - } - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function setBlockScopeContainer(node, cleanLocals) { - blockScopeContainer = node; - if (cleanLocals) { - blockScopeContainer.locals = undefined; - } - } - function addDeclarationToSymbol(symbol, node, symbolKind) { - symbol.flags |= symbolKind; - if (!symbol.declarations) - symbol.declarations = []; - symbol.declarations.push(node); - if (symbolKind & 1952 && !symbol.exports) - symbol.exports = {}; - if (symbolKind & 6240 && !symbol.members) - symbol.members = {}; - node.symbol = symbol; - if (symbolKind & 107455 && !symbol.valueDeclaration) - symbol.valueDeclaration = node; - } - function getDeclarationName(node) { - if (node.name) { - if (node.kind === 200 && node.name.kind === 8) { - return '"' + node.name.text + '"'; - } - if (node.name.kind === 126) { - var nameExpression = node.name.expression; - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); - } - return node.name.text; - } - switch (node.kind) { - case 141: - case 133: - return "__constructor"; - case 140: - case 136: - return "__call"; - case 137: - return "__new"; - case 138: - return "__index"; - case 210: - return "__export"; - case 209: - return "default"; - case 195: - case 196: - return node.flags & 256 ? "default" : undefined; - } - } - function getDisplayName(node) { - return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); - } - function declareSymbol(symbols, parent, node, includes, excludes) { - ts.Debug.assert(!ts.hasDynamicName(node)); - var _name = node.flags & 256 && parent ? "default" : getDeclarationName(node); - var symbol; - if (_name !== undefined) { - symbol = ts.hasProperty(symbols, _name) ? symbols[_name] : (symbols[_name] = createSymbol(0, _name)); - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } - var message = symbol.flags & 2 - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0, _name); - } - } - else { - symbol = createSymbol(0, "__missing"); - } - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - if (node.kind === 196 && symbol.exports) { - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - return symbol; - } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) - return true; - node = node.parent; - } - return false; - } - function declareModuleMember(node, symbolKind, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; - if (symbolKind & 8388608) { - if (node.kind === 212 || (node.kind === 203 && hasExportModifier)) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - } - else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - } - } - else { - if (hasExportModifier || isAmbientContext(container)) { - var exportKind = (symbolKind & 107455 ? 1048576 : 0) | - (symbolKind & 793056 ? 2097152 : 0) | - (symbolKind & 1536 ? 4194304 : 0); - var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); - local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - node.localSymbol = local; - } - else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - } - } - } - function bindChildren(node, symbolKind, isBlockScopeContainer) { - if (symbolKind & 255504) { - node.locals = {}; - } - var saveParent = _parent; - var saveContainer = container; - var savedBlockScopeContainer = blockScopeContainer; - _parent = node; - if (symbolKind & 262128) { - container = node; - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; - } - if (isBlockScopeContainer) { - setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 221); - } - ts.forEachChild(node, bind); - container = saveContainer; - _parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { - switch (container.kind) { - case 200: - declareModuleMember(node, symbolKind, symbolExcludes); - break; - case 221: - if (ts.isExternalModule(container)) { - declareModuleMember(node, symbolKind, symbolExcludes); - break; - } - case 140: - case 141: - case 136: - case 137: - case 138: - case 132: - case 131: - case 133: - case 134: - case 135: - case 195: - case 160: - case 161: - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - break; - case 196: - if (node.flags & 128) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - break; - } - case 143: - case 152: - case 197: - declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); - break; - case 199: - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - break; - } - bindChildren(node, symbolKind, isBlockScopeContainer); - } - function bindModuleDeclaration(node) { - if (node.name.kind === 8) { - bindDeclaration(node, 512, 106639, true); - } - else { - var state = getModuleInstanceState(node); - if (state === 0) { - bindDeclaration(node, 1024, 0, true); - } - else { - bindDeclaration(node, 512, 106639, true); - if (state === 2) { - node.symbol.constEnumOnlyModule = true; - } - else if (node.symbol.constEnumOnlyModule) { - node.symbol.constEnumOnlyModule = false; - } - } - } - } - function bindFunctionOrConstructorType(node) { - var symbol = createSymbol(131072, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, 131072); - bindChildren(node, 131072, false); - var typeLiteralSymbol = createSymbol(2048, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048); - typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 140 ? "__call" : "__new"] = symbol; - } - function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { - var symbol = createSymbol(symbolKind, name); - addDeclarationToSymbol(symbol, node, symbolKind); - bindChildren(node, symbolKind, isBlockScopeContainer); - } - function bindCatchVariableDeclaration(node) { - bindChildren(node, 0, true); - } - function bindBlockScopedVariableDeclaration(node) { - switch (blockScopeContainer.kind) { - case 200: - declareModuleMember(node, 2, 107455); - break; - case 221: - if (ts.isExternalModule(container)) { - declareModuleMember(node, 2, 107455); - break; - } - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; - } - declareSymbol(blockScopeContainer.locals, undefined, node, 2, 107455); - } - bindChildren(node, 2, false); - } - function getDestructuringParameterName(node) { - return "__" + ts.indexOf(node.parent.parameters, node); - } - function bind(node) { - node.parent = _parent; - switch (node.kind) { - case 127: - bindDeclaration(node, 262144, 530912, false); - break; - case 128: - bindParameter(node); - break; - case 193: - case 150: - if (ts.isBindingPattern(node.name)) { - bindChildren(node, 0, false); - } - else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); - } - else { - bindDeclaration(node, 1, 107454, false); - } - break; - case 130: - case 129: - bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); - break; - case 218: - case 219: - bindPropertyOrMethodOrAccessor(node, 4, 107455, false); - break; - case 220: - bindPropertyOrMethodOrAccessor(node, 8, 107455, false); - break; - case 136: - case 137: - case 138: - bindDeclaration(node, 131072, 0, false); - break; - case 132: - case 131: - bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); - break; - case 195: - bindDeclaration(node, 16, 106927, true); - break; - case 133: - bindDeclaration(node, 16384, 0, true); - break; - case 134: - bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); - break; - case 135: - bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); - break; - case 140: - case 141: - bindFunctionOrConstructorType(node); - break; - case 143: - bindAnonymousDeclaration(node, 2048, "__type", false); - break; - case 152: - bindAnonymousDeclaration(node, 4096, "__object", false); - break; - case 160: - case 161: - bindAnonymousDeclaration(node, 16, "__function", true); - break; - case 217: - bindCatchVariableDeclaration(node); - break; - case 196: - bindDeclaration(node, 32, 899583, false); - break; - case 197: - bindDeclaration(node, 64, 792992, false); - break; - case 198: - bindDeclaration(node, 524288, 793056, false); - break; - case 199: - if (ts.isConst(node)) { - bindDeclaration(node, 128, 899967, false); - } - else { - bindDeclaration(node, 256, 899327, false); - } - break; - case 200: - bindModuleDeclaration(node); - break; - case 203: - case 206: - case 208: - case 212: - bindDeclaration(node, 8388608, 8388608, false); - break; - case 205: - if (node.name) { - bindDeclaration(node, 8388608, 8388608, false); - } - else { - bindChildren(node, 0, false); - } - break; - case 210: - if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); - } - bindChildren(node, 0, false); - break; - case 209: - if (node.expression.kind === 64) { - declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 8388608); - } - else { - declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455); - } - bindChildren(node, 0, false); - break; - case 221: - if (ts.isExternalModule(node)) { - bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); - break; - } - case 174: - bindChildren(node, 0, !ts.isFunctionLike(node.parent)); - break; - case 217: - case 181: - case 182: - case 183: - case 202: - bindChildren(node, 0, true); - break; - default: - var saveParent = _parent; - _parent = node; - ts.forEachChild(node, bind); - _parent = saveParent; - } - } - function bindParameter(node) { - if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node), false); - } - else { - bindDeclaration(node, 1, 107455, false); - } - if (node.flags & 112 && - node.parent.kind === 133 && - node.parent.parent.kind === 196) { - var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); - } - } - function bindPropertyOrMethodOrAccessor(node, symbolKind, symbolExcludes, isBlockScopeContainer) { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer); - } - else { - bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer); - } - } - } -})(ts || (ts = {})); +/// var ts; (function (ts) { var nextSymbolId = 1; var nextNodeId = 1; var nextMergeId = 1; + function getNodeId(node) { + if (!node.id) + node.id = nextNodeId++; + return node.id; + } + ts.getNodeId = getNodeId; ts.checkTime = 0; + function getSymbolId(symbol) { + if (!symbol.id) { + symbol.id = nextSymbolId++; + } + return symbol.id; + } + ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -8278,7 +8885,6 @@ var ts; var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); var globals = {}; @@ -8295,10 +8901,16 @@ var ts; var globalESSymbolType; var globalIterableType; var anyArrayType; + var globalTypedPropertyDescriptorType; + var globalClassDecoratorType; + var globalParameterDecoratorType; + var globalPropertyDecoratorType; + var globalMethodDecoratorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; var emitExtends = false; + var emitDecorate = false; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -8453,20 +9065,18 @@ var ts; function getSymbolLinks(symbol) { if (symbol.flags & 67108864) return symbol; - if (!symbol.id) - symbol.id = nextSymbolId++; - return symbolLinks[symbol.id] || (symbolLinks[symbol.id] = {}); + var id = getSymbolId(symbol); + return symbolLinks[id] || (symbolLinks[id] = {}); } function getNodeLinks(node) { - if (!node.id) - node.id = nextNodeId++; - return nodeLinks[node.id] || (nodeLinks[node.id] = {}); + var nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 221); + return ts.getAncestor(node, 224); } function isGlobalSourceFile(node) { - return node.kind === 221 && !ts.isExternalModule(node); + return node.kind === 224 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -8500,6 +9110,7 @@ var ts; var lastLocation; var propertyWithInvalidInitializer; var errorLocation = location; + var grandparent; loop: while (location) { if (location.locals && !isGlobalSourceFile(location)) { if (result = getSymbol(location.locals, name, meaning)) { @@ -8507,25 +9118,25 @@ var ts; } } switch (location.kind) { - case 221: + case 224: if (!ts.isExternalModule(location)) break; - case 200: + case 202: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (!(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 212)) { + if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 214)) { break loop; } result = undefined; } break; - case 199: + case 201: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 130: - case 129: - if (location.parent.kind === 196 && !(location.flags & 128)) { + case 132: + case 131: + if (location.parent.kind === 198 && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -8534,8 +9145,8 @@ var ts; } } break; - case 196: - case 197: + case 198: + case 199: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -8544,28 +9155,28 @@ var ts; break loop; } break; - case 126: - var grandparent = location.parent.parent; - if (grandparent.kind === 196 || grandparent.kind === 197) { + case 127: + grandparent = location.parent.parent; + if (grandparent.kind === 198 || grandparent.kind === 199) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 132: - case 131: - case 133: case 134: + case 133: case 135: - case 195: - case 161: + case 136: + case 137: + case 197: + case 163: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 160: + case 162: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -8576,6 +9187,14 @@ var ts; break loop; } break; + case 130: + if (location.parent && location.parent.kind === 129) { + location = location.parent; + } + if (location.parent && ts.isClassElement(location.parent)) { + location = location.parent; + } + break; } lastLocation = location; location = location.parent; @@ -8607,14 +9226,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 193); + var variableDeclaration = ts.getAncestor(declaration, 195); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 175 || - variableDeclaration.parent.parent.kind === 181) { + if (variableDeclaration.parent.parent.kind === 177 || + variableDeclaration.parent.parent.kind === 183) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 183 || - variableDeclaration.parent.parent.kind === 182) { + else if (variableDeclaration.parent.parent.kind === 185 || + variableDeclaration.parent.parent.kind === 184) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -8634,49 +9253,94 @@ var ts; } return false; } - function isAliasSymbolDeclaration(node) { - return node.kind === 203 || - node.kind === 205 && !!node.name || - node.kind === 206 || - node.kind === 208 || - node.kind === 212 || - node.kind === 209; + function getAnyImportSyntax(node) { + if (ts.isAliasSymbolDeclaration(node)) { + if (node.kind === 205) { + return node; + } + while (node && node.kind !== 206) { + node = node.parent; + } + return node; + } } function getDeclarationOfAliasSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return isAliasSymbolDeclaration(d) ? d : undefined; }); + return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 213) { - var moduleSymbol = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node)); - var exportAssignmentSymbol = moduleSymbol && getResolvedExportAssignmentSymbol(moduleSymbol); - return exportAssignmentSymbol || moduleSymbol; + if (node.moduleReference.kind === 216) { + return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportAssignmentSymbol = getResolvedExportAssignmentSymbol(moduleSymbol); - if (!exportAssignmentSymbol) { - error(node.name, ts.Diagnostics.External_module_0_has_no_default_export_or_export_assignment, symbolToString(moduleSymbol)); + var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, ts.Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); } - return exportAssignmentSymbol; + return exportDefaultSymbol; } } function getTargetOfNamespaceImport(node) { - return resolveExternalModuleName(node, node.parent.parent.moduleSpecifier); + var moduleSpecifier = node.parent.parent.moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + function getMemberOfModuleVariable(moduleSymbol, name) { + if (moduleSymbol.flags & 3) { + var typeAnnotation = moduleSymbol.valueDeclaration.type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { + if (valueSymbol.flags & (793056 | 1536)) { + return valueSymbol; + } + var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) + result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) + result.members = typeSymbol.members; + if (valueSymbol.exports) + result.exports = valueSymbol.exports; + return result; + } + function getExportOfModule(symbol, name) { + if (symbol.flags & 1536) { + var exports = getExportsOfSymbol(symbol); + if (ts.hasProperty(exports, name)) { + return resolveSymbol(exports[name]); + } + } + } + function getPropertyOfVariable(symbol, name) { + if (symbol.flags & 3) { + var typeAnnotation = symbol.valueDeclaration.type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } } function getExternalModuleMember(node, specifier) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol) { - var _name = specifier.propertyName || specifier.name; - if (_name.text) { - var symbol = getSymbol(getExportsOfSymbol(moduleSymbol), _name.text, 107455 | 793056 | 1536); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { + var name_4 = specifier.propertyName || specifier.name; + if (name_4.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_4.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_4.text); + var symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; if (!symbol) { - error(_name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(_name)); - return; + error(name_4, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_4)); } - return symbol.flags & (107455 | 793056 | 1536) ? symbol : resolveAlias(symbol); + return symbol; } } } @@ -8689,31 +9353,34 @@ var ts; resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536); } function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793056 | 1536); + return node.expression && resolveEntityName(node.expression, 107455 | 793056 | 1536); } - function getTargetOfImportDeclaration(node) { + function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 203: - return getTargetOfImportEqualsDeclaration(node); case 205: + return getTargetOfImportEqualsDeclaration(node); + case 207: return getTargetOfImportClause(node); - case 206: - return getTargetOfNamespaceImport(node); case 208: + return getTargetOfNamespaceImport(node); + case 210: return getTargetOfImportSpecifier(node); - case 212: + case 214: return getTargetOfExportSpecifier(node); - case 209: + case 211: return getTargetOfExportAssignment(node); } } + function resolveSymbol(symbol) { + return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793056 | 1536)) ? resolveAlias(symbol) : symbol; + } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - var target = getTargetOfImportDeclaration(node); + var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -8738,10 +9405,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 209) { + if (node.kind === 211 && node.expression) { checkExpressionCached(node.expression); } - else if (node.kind === 212) { + else if (node.kind === 214) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -8751,17 +9418,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 203); + importDeclaration = ts.getAncestor(entityName, 205); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 64 && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 65 && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 64 || entityName.parent.kind === 125) { + if (entityName.kind === 65 || entityName.parent.kind === 126) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 203); + ts.Debug.assert(entityName.parent.kind === 205); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -8773,13 +9440,13 @@ var ts; return undefined; } var symbol; - if (name.kind === 64) { + if (name.kind === 65) { symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return undefined; } } - else if (name.kind === 125) { + else if (name.kind === 126) { var namespace = resolveEntityName(name.left, 1536); if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) { return undefined; @@ -8835,22 +9502,22 @@ var ts; } error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["default"]; + function resolveExternalModuleSymbol(moduleSymbol) { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; } - function getResolvedExportAssignmentSymbol(moduleSymbol) { - var symbol = getExportAssignmentSymbol(moduleSymbol); - if (symbol) { - if (symbol.flags & (107455 | 793056 | 1536)) { - return symbol; - } - if (symbol.flags & 8388608) { - return resolveAlias(symbol); - } + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { + var symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (1536 | 3))) { + error(moduleReferenceExpression, ts.Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; } + return symbol; + } + function getExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="]; } function getExportsOfSymbol(symbol) { - return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports; + return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { var links = getSymbolLinks(moduleSymbol); @@ -8864,20 +9531,12 @@ var ts; } } function getExportsForModule(moduleSymbol) { - if (compilerOptions.target < 2) { - var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - return { - "default": defaultSymbol - }; - } - } var result; var visitedSymbols = []; visit(moduleSymbol); return result || moduleSymbol.exports; function visit(symbol) { - if (!ts.contains(visitedSymbols, symbol)) { + if (symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol)) { visitedSymbols.push(symbol); if (symbol !== moduleSymbol) { if (!result) { @@ -8887,9 +9546,10 @@ var ts; } var exportStars = symbol.exports["__export"]; if (exportStars) { - ts.forEach(exportStars.declarations, function (node) { + for (var _i = 0, _a = exportStars.declarations, _n = _a.length; _i < _n; _i++) { + var node = _a[_i]; visit(resolveExternalModuleName(node, node.moduleSpecifier)); - }); + } } } } @@ -8925,7 +9585,7 @@ var ts; var members = node.members; for (var _i = 0, _n = members.length; _i < _n; _i++) { var member = members[_i]; - if (member.kind === 133 && ts.nodeIsPresent(member.body)) { + if (member.kind === 135 && ts.nodeIsPresent(member.body)) { return member; } } @@ -8983,25 +9643,25 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var _location = enclosingDeclaration; _location; _location = _location.parent) { - if (_location.locals && !isGlobalSourceFile(_location)) { - if (result = callback(_location.locals)) { + for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + if (location_1.locals && !isGlobalSourceFile(location_1)) { + if (result = callback(location_1.locals)) { return result; } } - switch (_location.kind) { - case 221: - if (!ts.isExternalModule(_location)) { + switch (location_1.kind) { + case 224: + if (!ts.isExternalModule(location_1)) { break; } - case 200: - if (result = callback(getSymbolOfNode(_location).exports)) { + case 202: + if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 196: - case 197: - if (result = callback(getSymbolOfNode(_location).members)) { + case 198: + case 199: + if (result = callback(getSymbolOfNode(location_1).members)) { return result; } break; @@ -9115,8 +9775,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 200 && declaration.name.kind === 8) || - (declaration.kind === 221 && ts.isExternalModule(declaration)); + return (declaration.kind === 202 && declaration.name.kind === 8) || + (declaration.kind === 224 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -9126,17 +9786,18 @@ var ts; return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 203 && - !(declaration.flags & 1) && - isDeclarationVisible(declaration.parent)) { + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & 1) && + isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, declaration)) { - aliasesToMakeVisible.push(declaration); + if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); } } else { - aliasesToMakeVisible = [declaration]; + aliasesToMakeVisible = [anyImportSyntax]; } return true; } @@ -9147,11 +9808,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 142) { + if (entityName.parent.kind === 144) { meaning = 107455 | 1048576; } - else if (entityName.kind === 125 || - entityName.parent.kind === 203) { + else if (entityName.kind === 126 || + entityName.parent.kind === 205) { meaning = 1536; } else { @@ -9195,10 +9856,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 147) { + while (node.kind === 149) { node = node.parent; } - if (node.kind === 198) { + if (node.kind === 200) { return getSymbolOfNode(node); } } @@ -9352,7 +10013,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 111); + writeKeyword(writer, 112); } } else { @@ -9370,7 +10031,7 @@ var ts; var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { - return declaration.parent.kind === 221 || declaration.parent.kind === 201; + return declaration.parent.kind === 224 || declaration.parent.kind === 203; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -9380,7 +10041,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 96); + writeKeyword(writer, 97); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -9414,7 +10075,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 16); } - writeKeyword(writer, 87); + writeKeyword(writer, 88); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, typeStack); if (flags & 64) { @@ -9433,10 +10094,10 @@ var ts; writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures, _d = _c.length; _b < _d; _b++) { - var _signature = _c[_b]; - writeKeyword(writer, 87); + var signature = _c[_b]; + writeKeyword(writer, 88); writeSpace(writer); - buildSignatureDisplay(_signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); writePunctuation(writer, 22); writer.writeLine(); } @@ -9445,7 +10106,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 120); + writeKeyword(writer, 121); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -9458,7 +10119,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 118); + writeKeyword(writer, 119); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -9472,12 +10133,12 @@ var ts; if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); for (var _h = 0, _j = signatures.length; _h < _j; _h++) { - var _signature_1 = signatures[_h]; + var signature = signatures[_h]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { writePunctuation(writer, 50); } - buildSignatureDisplay(_signature_1, writer, enclosingDeclaration, globalFlagsToPass, typeStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); writePunctuation(writer, 22); writer.writeLine(); } @@ -9509,7 +10170,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 78); + writeKeyword(writer, 79); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } @@ -9602,12 +10263,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 200) { + if (node.kind === 202) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 221) { + else if (node.kind === 224) { return ts.isExternalModule(node) ? node : undefined; } } @@ -9650,47 +10311,56 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 193: - case 150: - case 200: - case 196: - case 197: - case 198: + case 152: + return isDeclarationVisible(node.parent.parent); case 195: - case 199: - case 203: - var _parent = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 203 && _parent.kind !== 221 && ts.isInAmbientContext(_parent))) { - return isGlobalSourceFile(_parent) || isUsedInExportAssignment(node); + if (ts.isBindingPattern(node.name) && + !node.name.elements.length) { + return false; } - return isDeclarationVisible(_parent); - case 130: - case 129: - case 134: - case 135: + case 202: + case 198: + case 199: + case 200: + case 197: + case 201: + case 205: + var parent_2 = getDeclarationContainer(node); + if (!(ts.getCombinedNodeFlags(node) & 1) && + !(node.kind !== 205 && parent_2.kind !== 224 && ts.isInAmbientContext(parent_2))) { + return isGlobalSourceFile(parent_2); + } + return isDeclarationVisible(parent_2); case 132: case 131: + case 136: + case 137: + case 134: + case 133: if (node.flags & (32 | 64)) { return false; } - case 133: - case 137: - case 136: - case 138: - case 128: - case 201: - case 140: - case 141: - case 143: + case 135: case 139: - case 144: + case 138: + case 140: + case 129: + case 203: + case 142: + case 143: case 145: + case 141: case 146: case 147: + case 148: + case 149: return isDeclarationVisible(node.parent); - case 127: - case 221: + case 207: + case 208: + case 210: + return false; + case 128: + case 224: return true; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -9704,15 +10374,44 @@ var ts; return links.isVisible; } } + function collectLinkedAliases(node) { + var exportSymbol; + if (node.parent && node.parent.kind === 211) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === 214) { + exportSymbol = getTargetOfExportSpecifier(node.parent); + } + var result = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + function buildVisibleNodeList(declarations) { + ts.forEach(declarations, function (declaration) { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!ts.contains(result, resultNode)) { + result.push(resultNode); + } + if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { + var internalModuleReference = declaration.moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } function getRootDeclaration(node) { - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent.parent; } return node; } function getDeclarationContainer(node) { node = getRootDeclaration(node); - return node.kind === 193 ? node.parent.parent.parent : node.parent; + return node.kind === 195 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -9735,13 +10434,13 @@ var ts; return parentType; } var type; - if (pattern.kind === 148) { - var _name = declaration.propertyName || declaration.name; - type = getTypeOfPropertyOfType(parentType, _name.text) || - isNumericLiteralName(_name.text) && getIndexTypeOfType(parentType, 1) || + if (pattern.kind === 150) { + var name_5 = declaration.propertyName || declaration.name; + type = getTypeOfPropertyOfType(parentType, name_5.text) || + isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(_name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(_name)); + error(name_5, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_5)); return unknownType; } } @@ -9770,10 +10469,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 182) { + if (declaration.parent.parent.kind === 184) { return anyType; } - if (declaration.parent.parent.kind === 183) { + if (declaration.parent.parent.kind === 185) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -9782,10 +10481,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 128) { + if (declaration.kind === 129) { var func = declaration.parent; - if (func.kind === 135 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 134); + if (func.kind === 137 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 136); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -9798,7 +10497,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 219) { + if (declaration.kind === 222) { return checkIdentifier(declaration.name); } return undefined; @@ -9816,8 +10515,8 @@ var ts; var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); - var _name = e.propertyName || e.name; - var symbol = createSymbol(flags, _name.text); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); symbol.type = getTypeFromBindingElement(e); members[symbol.name] = symbol; }); @@ -9827,7 +10526,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 172 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 174 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -9835,7 +10534,7 @@ var ts; return !elementTypes.length ? anyArrayType : hasSpreadElement ? createArrayType(getUnionType(elementTypes)) : createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 148 + return pattern.kind === 150 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -9845,7 +10544,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 218 ? getWidenedType(type) : type; + return declaration.kind !== 221 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -9853,7 +10552,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 128 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 129 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -9866,11 +10565,20 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 217) { + if (declaration.parent.kind === 220) { return links.type = anyType; } - if (declaration.kind === 209) { - return links.type = checkExpression(declaration.expression); + if (declaration.kind === 211) { + var exportAssignment = declaration; + if (exportAssignment.expression) { + return links.type = checkExpression(exportAssignment.expression); + } + else if (exportAssignment.type) { + return links.type = getTypeFromTypeNode(exportAssignment.type); + } + else { + return links.type = anyType; + } } links.type = resolvingType; var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -9894,7 +10602,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 134) { + if (accessor.kind === 136) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -9913,8 +10621,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 134); - var setter = ts.getDeclarationOfKind(symbol, 135); + var getter = ts.getDeclarationOfKind(symbol, 136); + var setter = ts.getDeclarationOfKind(symbol, 137); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -9944,8 +10652,8 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var _getter = ts.getDeclarationOfKind(symbol, 134); - error(_getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + var getter = ts.getDeclarationOfKind(symbol, 136); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } } @@ -10011,7 +10719,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 197 || node.kind === 196) { + if (node.kind === 199 || node.kind === 198) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -10042,7 +10750,7 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(symbol, 196); + var declaration = ts.getDeclarationOfKind(symbol, 198); var baseTypeNode = ts.getClassBaseTypeNode(declaration); if (baseTypeNode) { var baseType = getTypeFromTypeReferenceNode(baseTypeNode); @@ -10083,7 +10791,7 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 197 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 199 && ts.getInterfaceBaseTypeNodes(declaration)) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { @@ -10114,7 +10822,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 198); + var declaration = ts.getDeclarationOfKind(symbol, 200); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -10122,8 +10830,8 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var _declaration = ts.getDeclarationOfKind(symbol, 198); - error(_declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + var declaration = ts.getDeclarationOfKind(symbol, 200); + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; } @@ -10141,7 +10849,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 127).constraint) { + if (!ts.getDeclarationOfKind(symbol, 128).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -10308,8 +11016,8 @@ var ts; return emptyArray; } } - for (var _i_1 = 1; _i_1 < signatureLists.length; _i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[_i_1])) { + for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { + if (!signatureListsIdentical(signatures, signatureLists[i_1])) { return emptyArray; } } @@ -10478,11 +11186,11 @@ var ts; var propTypes = []; var declarations = []; for (var _a = 0, _b = props.length; _a < _b; _a++) { - var _prop = props[_a]; - if (_prop.declarations) { - declarations.push.apply(declarations, _prop.declarations); + var prop = props[_a]; + if (prop.declarations) { + declarations.push.apply(declarations, prop.declarations); } - propTypes.push(getTypeOfSymbol(_prop)); + propTypes.push(getTypeOfSymbol(prop)); } var result = createSymbol(4 | 67108864 | 268435456, name); result.unionType = unionType; @@ -10519,9 +11227,9 @@ var ts; } } if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - var _symbol = getPropertyOfObjectType(globalFunctionType, name); - if (_symbol) - return _symbol; + var symbol = getPropertyOfObjectType(globalFunctionType, name); + if (symbol) + return symbol; } return getPropertyOfObjectType(globalObjectType, name); } @@ -10554,20 +11262,29 @@ var ts; }); return result; } + function symbolsToArray(symbols) { + var result = []; + for (var id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } function getExportsOfExternalModule(node) { if (!node.moduleSpecifier) { return emptyArray; } var module = resolveExternalModuleName(node, node.moduleSpecifier); - if (!module || !module.exports) { + if (!module) { return emptyArray; } - return ts.mapToArray(getExportsOfModule(module)); + return symbolsToArray(getExportsOfModule(module)); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 133 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 135 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -10596,8 +11313,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 134 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 135); + if (declaration.kind === 136 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 137); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -10615,19 +11332,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 140: - case 141: - case 195: - case 132: - case 131: + case 142: + case 143: + case 197: + case 134: case 133: + case 135: + case 138: + case 139: + case 140: case 136: case 137: - case 138: - case 134: - case 135: - case 160: - case 161: + case 162: + case 163: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -10697,7 +11414,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 133 || signature.declaration.kind === 137; + var isConstructor = signature.declaration.kind === 135 || signature.declaration.kind === 139; var type = createObjectType(32768 | 65536); type.members = emptySymbols; type.properties = emptyArray; @@ -10711,7 +11428,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 118 : 120; + var syntaxKind = kind === 1 ? 119 : 121; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -10741,7 +11458,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 127).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 128).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -10791,13 +11508,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 127; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 128; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 139 && n.typeName.kind === 64) { + if (n.kind === 141 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -10862,9 +11579,9 @@ var ts; for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 196: - case 197: + case 198: case 199: + case 201: return declaration; } } @@ -11041,38 +11758,38 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 111: - return anyType; - case 120: - return stringType; - case 118: - return numberType; case 112: - return booleanType; + return anyType; case 121: + return stringType; + case 119: + return numberType; + case 113: + return booleanType; + case 122: return esSymbolType; - case 98: + case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 139: - return getTypeFromTypeReferenceNode(node); - case 142: - return getTypeFromTypeQueryNode(node); - case 144: - return getTypeFromArrayTypeNode(node); - case 145: - return getTypeFromTupleTypeNode(node); - case 146: - return getTypeFromUnionTypeNode(node); - case 147: - return getTypeFromTypeNode(node.type); - case 140: case 141: + return getTypeFromTypeReferenceNode(node); + case 144: + return getTypeFromTypeQueryNode(node); + case 146: + return getTypeFromArrayTypeNode(node); + case 147: + return getTypeFromTupleTypeNode(node); + case 148: + return getTypeFromUnionTypeNode(node); + case 149: + return getTypeFromTypeNode(node.type); + case 142: case 143: + case 145: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 64: - case 125: + case 65: + case 126: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -11135,6 +11852,7 @@ var ts; return function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; return getInferredType(context, i); } } @@ -11222,27 +11940,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 160: - case 161: + case 162: + case 163: return isContextSensitiveFunctionLikeDeclaration(node); - case 152: + case 154: return ts.forEach(node.properties, isContextSensitive); - case 151: + case 153: return ts.forEach(node.elements, isContextSensitive); - case 168: + case 170: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 167: + case 169: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 218: + case 221: return isContextSensitive(node.initializer); - case 132: - case 131: + case 134: + case 133: return isContextSensitiveFunctionLikeDeclaration(node); - case 159: + case 161: return isContextSensitive(node.expression); } return false; @@ -11298,6 +12016,7 @@ var ts; var expandingFlags; var depth = 0; var overflow = false; + var elaborateErrors = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); if (overflow) { @@ -11306,7 +12025,8 @@ var ts; else if (errorInfo) { if (errorInfo.next === undefined) { errorInfo = undefined; - isRelatedTo(source, target, errorNode !== undefined, headMessage, true); + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); } if (containingMessageChain) { errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); @@ -11317,9 +12037,8 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } - function isRelatedTo(source, target, reportErrors, headMessage, elaborateErrors) { - if (elaborateErrors === void 0) { elaborateErrors = false; } - var _result; + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; if (source === target) return -1; if (relation !== identityRelation) { @@ -11343,54 +12062,54 @@ var ts; if (source.flags & 16384 || target.flags & 16384) { if (relation === identityRelation) { if (source.flags & 16384 && target.flags & 16384) { - if (_result = unionTypeRelatedToUnionType(source, target)) { - if (_result &= unionTypeRelatedToUnionType(target, source)) { - return _result; + if (result = unionTypeRelatedToUnionType(source, target)) { + if (result &= unionTypeRelatedToUnionType(target, source)) { + return result; } } } else if (source.flags & 16384) { - if (_result = unionTypeRelatedToType(source, target, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; } } else { - if (_result = unionTypeRelatedToType(target, source, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(target, source, reportErrors)) { + return result; } } } else { if (source.flags & 16384) { - if (_result = unionTypeRelatedToType(source, target, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; } } else { - if (_result = typeRelatedToUnionType(source, target, reportErrors)) { - return _result; + if (result = typeRelatedToUnionType(source, target, reportErrors)) { + return result; } } } } else if (source.flags & 512 && target.flags & 512) { - if (_result = typeParameterRelatedTo(source, target, reportErrors)) { - return _result; + if (result = typeParameterRelatedTo(source, target, reportErrors)) { + return result; } } else { var saveErrorInfo = errorInfo; if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (_result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return _result; + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); if (sourceOrApparentType.flags & 48128 && target.flags & 48128 && - (_result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors, elaborateErrors))) { + (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { errorInfo = saveErrorInfo; - return _result; + return result; } } if (reportErrors) { @@ -11406,7 +12125,7 @@ var ts; return 0; } function unionTypeRelatedToUnionType(source, target) { - var _result = -1; + var result = -1; var sourceTypes = source.types; for (var _i = 0, _n = sourceTypes.length; _i < _n; _i++) { var sourceType = sourceTypes[_i]; @@ -11414,9 +12133,9 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typeRelatedToUnionType(source, target, reportErrors) { var targetTypes = target.types; @@ -11429,7 +12148,7 @@ var ts; return 0; } function unionTypeRelatedToType(source, target, reportErrors) { - var _result = -1; + var result = -1; var sourceTypes = source.types; for (var _i = 0, _n = sourceTypes.length; _i < _n; _i++) { var sourceType = sourceTypes[_i]; @@ -11437,20 +12156,20 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typesRelatedTo(sources, targets, reportErrors) { - var _result = -1; + var result = -1; for (var i = 0, len = sources.length; i < len; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typeParameterRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { @@ -11477,8 +12196,7 @@ var ts; return 0; } } - function objectTypeRelatedTo(source, target, reportErrors, elaborateErrors) { - if (elaborateErrors === void 0) { elaborateErrors = false; } + function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0; } @@ -11516,20 +12234,20 @@ var ts; expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) expandingFlags |= 2; - var _result; + var result; if (expandingFlags === 3) { - _result = 1; + result = 1; } else { - _result = propertiesRelatedTo(source, target, reportErrors); - if (_result) { - _result &= signaturesRelatedTo(source, target, 0, reportErrors); - if (_result) { - _result &= signaturesRelatedTo(source, target, 1, reportErrors); - if (_result) { - _result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (_result) { - _result &= numberIndexTypesRelatedTo(source, target, reportErrors); + result = propertiesRelatedTo(source, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(source, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(source, target, reportErrors); } } } @@ -11537,23 +12255,23 @@ var ts; } expandingFlags = saveExpandingFlags; depth--; - if (_result) { + if (result) { var maybeCache = maybeStack[depth]; - var destinationCache = (_result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; + var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; ts.copyMap(maybeCache, destinationCache); } else { relation[id] = reportErrors ? 3 : 2; } - return _result; + return result; } function isDeeplyNestedGeneric(type, stack) { if (type.flags & 4096 && depth >= 10) { - var _target = type.target; + var target_1 = type.target; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 4096 && t.target === _target) { + if (t.flags & 4096 && t.target === target_1) { count++; if (count >= 10) return true; @@ -11566,7 +12284,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var _result = -1; + var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 131072); for (var _i = 0, _n = properties.length; _i < _n; _i++) { @@ -11621,7 +12339,7 @@ var ts; } return 0; } - _result &= related; + result &= related; if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); @@ -11631,7 +12349,7 @@ var ts; } } } - return _result; + return result; } function propertiesIdenticalTo(source, target) { var sourceProperties = getPropertiesOfObjectType(source); @@ -11639,7 +12357,7 @@ var ts; if (sourceProperties.length !== targetProperties.length) { return 0; } - var _result = -1; + var result = -1; for (var _i = 0, _n = sourceProperties.length; _i < _n; _i++) { var sourceProp = sourceProperties[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); @@ -11650,9 +12368,9 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function signaturesRelatedTo(source, target, kind, reportErrors) { if (relation === identityRelation) { @@ -11663,7 +12381,7 @@ var ts; } var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); - var _result = -1; + var result = -1; var saveErrorInfo = errorInfo; outer: for (var _i = 0, _n = targetSignatures.length; _i < _n; _i++) { var t = targetSignatures[_i]; @@ -11674,7 +12392,7 @@ var ts; if (!s.hasStringLiterals || source.flags & 65536) { var related = signatureRelatedTo(s, t, localErrors); if (related) { - _result &= related; + result &= related; errorInfo = saveErrorInfo; continue outer; } @@ -11684,7 +12402,7 @@ var ts; return 0; } } - return _result; + return result; } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -11714,14 +12432,14 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - var _result = -1; + var result = -1; for (var i = 0; i < checkCount; i++) { - var _s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var _t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var s_1 = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t_1 = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - var related = isRelatedTo(_s, _t, reportErrors); + var related = isRelatedTo(s_1, t_1, reportErrors); if (!related) { - related = isRelatedTo(_t, _s, false); + related = isRelatedTo(t_1, s_1, false); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); @@ -11730,13 +12448,13 @@ var ts; } errorInfo = saveErrorInfo; } - _result &= related; + result &= related; } var t = getReturnTypeOfSignature(target); if (t === voidType) - return _result; + return result; var s = getReturnTypeOfSignature(source); - return _result & isRelatedTo(s, t, reportErrors); + return result & isRelatedTo(s, t, reportErrors); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -11744,15 +12462,15 @@ var ts; if (sourceSignatures.length !== targetSignatures.length) { return 0; } - var _result = -1; + var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function stringIndexTypesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { @@ -11872,14 +12590,14 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var _i = 0, _len = source.parameters.length; _i < _len; _i++) { - var s = source.hasRestParameter && _i === _len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[_i]); - var t = target.hasRestParameter && _i === _len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[_i]); - var _related = compareTypes(s, t); - if (!_related) { + for (var i = 0, len = source.parameters.length; i < len; i++) { + var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var related = compareTypes(s, t); + if (!related) { return 0; } - result &= _related; + result &= related; } if (compareReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); @@ -11912,6 +12630,7 @@ var ts; downfallType = types[j]; } } + ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); if (score > bestSupertypeScore) { bestSupertype = types[i]; bestSupertypeDownfallType = downfallType; @@ -11992,17 +12711,17 @@ var ts; return reportWideningErrorsInType(type.typeArguments[0]); } if (type.flags & 131072) { - var _errorReported = false; + var errorReported = false; ts.forEach(getPropertiesOfObjectType(type), function (p) { var t = getTypeOfSymbol(p); if (t.flags & 262144) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } - _errorReported = true; + errorReported = true; } }); - return _errorReported; + return errorReported; } return false; } @@ -12010,22 +12729,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 130: - case 129: + case 132: + case 131: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 128: + case 129: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 195: - case 132: - case 131: + case 197: case 134: - case 135: - case 160: - case 161: + case 133: + case 136: + case 137: + case 162: + case 163: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -12074,12 +12793,11 @@ var ts; var inferences = []; for (var _i = 0, _n = typeParameters.length; _i < _n; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined }); + inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); } return { typeParameters: typeParameters, inferUnionTypes: inferUnionTypes, - inferenceCount: 0, inferences: inferences, inferredTypes: new Array(typeParameters.length) }; @@ -12100,11 +12818,11 @@ var ts; } function isWithinDepthLimit(type, stack) { if (depth >= 5) { - var _target = type.target; + var target_2 = type.target; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 4096 && t.target === _target) { + if (t.flags & 4096 && t.target === target_2) { count++; } } @@ -12121,28 +12839,31 @@ var ts; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { var inferences = context.inferences[i]; - var candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) - candidates.push(source); - break; + if (!inferences.isFixed) { + var candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!ts.contains(candidates, source)) { + candidates.push(source); + } + } + return; } } } else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { var sourceTypes = source.typeArguments; var targetTypes = target.typeArguments; - for (var _i = 0; _i < sourceTypes.length; _i++) { - inferFromTypes(sourceTypes[_i], targetTypes[_i]); + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); } } else if (target.flags & 16384) { - var _targetTypes = target.types; + var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - for (var _a = 0, _n = _targetTypes.length; _a < _n; _a++) { - var t = _targetTypes[_a]; + for (var _i = 0, _n = targetTypes.length; _i < _n; _i++) { + var t = targetTypes[_i]; if (t.flags & 512 && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -12158,9 +12879,9 @@ var ts; } } else if (source.flags & 16384) { - var _sourceTypes = source.types; - for (var _b = 0, _c = _sourceTypes.length; _b < _c; _b++) { - var sourceType = _sourceTypes[_b]; + var sourceTypes = source.types; + for (var _a = 0, _b = sourceTypes.length; _a < _b; _a++) { + var sourceType = sourceTypes[_a]; inferFromTypes(sourceType, target); } } @@ -12224,19 +12945,25 @@ var ts; } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; + var inferenceSucceeded; if (!inferredType) { var inferences = getInferenceCandidates(context, index); if (inferences.length) { var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType; + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; } else { inferredType = emptyObjectType; + inferenceSucceeded = true; } - if (inferredType !== inferenceFailureType) { + if (inferenceSucceeded) { var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + context.failedTypeParameterIndex = index; + } context.inferredTypes[index] = inferredType; } return inferredType; @@ -12260,10 +12987,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 142: + case 144: return true; - case 64: - case 125: + case 65: + case 126: node = node.parent; continue; default: @@ -12303,12 +13030,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 52 && node.operatorToken.kind <= 63) { + if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 159) { + while (n.kind === 161) { n = n.expression; } - if (n.kind === 64 && getResolvedSymbol(n) === symbol) { + if (n.kind === 65 && getResolvedSymbol(n) === symbol) { return true; } } @@ -12322,46 +13049,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 167: + case 169: return isAssignedInBinaryExpression(node); - case 193: - case 150: - return isAssignedInVariableDeclaration(node); - case 148: - case 149: - case 151: + case 195: case 152: + return isAssignedInVariableDeclaration(node); + case 150: + case 151: case 153: case 154: case 155: case 156: + case 157: case 158: - case 159: - case 165: - case 162: - case 163: + case 160: + case 161: + case 167: case 164: + case 165: case 166: case 168: - case 171: - case 174: - case 175: + case 170: + case 173: + case 176: case 177: - case 178: case 179: case 180: case 181: case 182: case 183: - case 186: - case 187: + case 184: + case 185: case 188: - case 214: - case 215: case 189: case 190: - case 191: case 217: + case 218: + case 191: + case 192: + case 193: + case 220: return ts.forEachChild(node, isAssignedIn); } return false; @@ -12369,10 +13096,10 @@ var ts; } function resolveLocation(node) { var containerNodes = []; - for (var _parent = node.parent; _parent; _parent = _parent.parent) { - if ((ts.isExpression(_parent) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(_parent)) { - containerNodes.unshift(_parent); + for (var parent_3 = node.parent; parent_3; parent_3 = parent_3.parent) { + if ((ts.isExpression(parent_3) || ts.isObjectLiteralMethod(node)) && + isContextSensitive(parent_3)) { + containerNodes.unshift(parent_3); } } ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); @@ -12397,17 +13124,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 178: + case 180: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 168: + case 170: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 167: + case 169: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -12417,14 +13144,14 @@ var ts; } } break; - case 221: - case 200: - case 195: - case 132: - case 131: + case 224: + case 202: + case 197: case 134: - case 135: case 133: + case 136: + case 137: + case 135: break loop; } if (narrowedType !== type) { @@ -12437,12 +13164,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 163 || expr.right.kind !== 8) { + if (expr.left.kind !== 165 || expr.right.kind !== 8) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 64 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 65 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -12488,7 +13215,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (type.flags & 1 || !assumeTrue || expr.left.kind !== 64 || getResolvedSymbol(expr.left) !== symbol) { + if (type.flags & 1 || !assumeTrue || expr.left.kind !== 65 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -12510,9 +13237,9 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 159: + case 161: return narrowType(type, expr.expression, assumeTrue); - case 167: + case 169: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -12523,11 +13250,11 @@ var ts; else if (operator === 49) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 86) { + else if (operator === 87) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 165: + case 167: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -12538,7 +13265,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 161) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 163) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -12562,15 +13289,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 217) { + symbol.valueDeclaration.parent.kind === 220) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 194) { + while (container.kind !== 196) { container = container.parent; } container = container.parent; - if (container.kind === 175) { + if (container.kind === 177) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -12587,9 +13314,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 196 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 198 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 130 || container.kind === 133) { + if (container.kind === 132 || container.kind === 135) { getNodeLinks(classNode).flags |= 4; } else { @@ -12599,36 +13326,36 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 161) { + if (container.kind === 163) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 200: + case 202: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 199: + case 201: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 133: + case 135: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 130: - case 129: + case 132: + case 131: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 126: + case 127: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 196 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 198 ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -12637,15 +13364,15 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 128) { + if (n.kind === 129) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 155 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 196); + var isCallExpression = node.parent.kind === 157 && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 198); var baseClass; if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -12660,31 +13387,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 133; + canUseSuperExpression = container.kind === 135; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 161) { + while (container && container.kind === 163) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 196) { + if (container && container.parent && container.parent.kind === 198) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 132 || - container.kind === 131 || - container.kind === 134 || - container.kind === 135; + container.kind === 134 || + container.kind === 133 || + container.kind === 136 || + container.kind === 137; } else { canUseSuperExpression = - container.kind === 132 || + container.kind === 134 || + container.kind === 133 || + container.kind === 136 || + container.kind === 137 || + container.kind === 132 || container.kind === 131 || - container.kind === 134 || - container.kind === 135 || - container.kind === 130 || - container.kind === 129 || - container.kind === 133; + container.kind === 135; } } } @@ -12698,7 +13425,7 @@ var ts; getNodeLinks(node).flags |= 16; returnType = baseClass; } - if (container.kind === 133 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 135 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -12708,7 +13435,7 @@ var ts; return returnType; } } - if (container.kind === 126) { + if (container.kind === 127) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -12746,7 +13473,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 128) { + if (declaration.kind === 129) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -12761,7 +13488,7 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 133 || func.kind === 134 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 135))) { + if (func.type || func.kind === 135 || func.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 137))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } var signature = getContextualSignatureForFunctionLikeDeclaration(func); @@ -12781,7 +13508,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 157) { + if (template.parent.kind === 159) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -12789,7 +13516,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 52 && operator <= 63) { + if (operator >= 53 && operator <= 64) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } @@ -12887,35 +13614,35 @@ var ts; if (node.contextualType) { return node.contextualType; } - var _parent = node.parent; - switch (_parent.kind) { - case 193: - case 128: - case 130: + var parent = node.parent; + switch (parent.kind) { + case 195: case 129: - case 150: + case 132: + case 131: + case 152: return getContextualTypeForInitializerExpression(node); - case 161: - case 186: + case 163: + case 188: return getContextualTypeForReturnExpression(node); - case 155: - case 156: - return getContextualTypeForArgument(_parent, node); + case 157: case 158: - return getTypeFromTypeNode(_parent.type); - case 167: + return getContextualTypeForArgument(parent, node); + case 160: + return getTypeFromTypeNode(parent.type); + case 169: return getContextualTypeForBinaryOperand(node); - case 218: - return getContextualTypeForObjectLiteralElement(_parent); - case 151: + case 221: + return getContextualTypeForObjectLiteralElement(parent); + case 153: return getContextualTypeForElementExpression(node); - case 168: + case 170: return getContextualTypeForConditionalOperand(node); - case 173: - ts.Debug.assert(_parent.parent.kind === 169); - return getContextualTypeForSubstitutionExpression(_parent.parent, node); - case 159: - return getContextualType(_parent); + case 175: + ts.Debug.assert(parent.parent.kind === 171); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 161: + return getContextualType(parent); } return undefined; } @@ -12929,13 +13656,13 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 160 || node.kind === 161; + return node.kind === 162 || node.kind === 163; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -12978,15 +13705,15 @@ var ts; return mapper && mapper !== identityMapper; } function isAssignmentTarget(node) { - var _parent = node.parent; - if (_parent.kind === 167 && _parent.operatorToken.kind === 52 && _parent.left === node) { + var parent = node.parent; + if (parent.kind === 169 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (_parent.kind === 218) { - return isAssignmentTarget(_parent.parent); + if (parent.kind === 221) { + return isAssignmentTarget(parent.parent); } - if (_parent.kind === 151) { - return isAssignmentTarget(_parent); + if (parent.kind === 153) { + return isAssignmentTarget(parent); } return false; } @@ -13007,7 +13734,7 @@ var ts; var elementTypes = []; ts.forEach(elements, function (e) { var type = checkExpression(e, contextualMapper); - if (e.kind === 171) { + if (e.kind === 173) { elementTypes.push(getIndexTypeOfType(type, 1) || anyType); hasSpreadElement = true; } @@ -13024,7 +13751,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 126 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 127 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return allConstituentTypesHaveKind(checkComputedPropertyName(name), 1 | 132); @@ -13054,19 +13781,19 @@ var ts; for (var _i = 0, _a = node.properties, _n = _a.length; _i < _n; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 218 || - memberDecl.kind === 219 || + if (memberDecl.kind === 221 || + memberDecl.kind === 222 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 218) { + if (memberDecl.kind === 221) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 132) { + else if (memberDecl.kind === 134) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 219); - type = memberDecl.name.kind === 126 + ts.Debug.assert(memberDecl.kind === 222); + type = memberDecl.name.kind === 127 ? unknownType : checkExpression(memberDecl.name, contextualMapper); } @@ -13082,7 +13809,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 134 || memberDecl.kind === 135); + ts.Debug.assert(memberDecl.kind === 136 || memberDecl.kind === 137); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -13101,21 +13828,21 @@ var ts; for (var i = 0; i < propertiesArray.length; i++) { var propertyDecl = node.properties[i]; if (kind === 0 || isNumericName(propertyDecl.name)) { - var _type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, _type)) { - propTypes.push(_type); + var type = getTypeOfSymbol(propertiesArray[i]); + if (!ts.contains(propTypes, type)) { + propTypes.push(type); } } } - var _result = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= _result.flags; - return _result; + var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; + typeFlags |= result_1.flags; + return result_1; } return undefined; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 130; + return s.valueDeclaration ? s.valueDeclaration.kind : 132; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -13125,7 +13852,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 196); + var enclosingClassDeclaration = ts.getAncestor(node, 198); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -13134,7 +13861,7 @@ var ts; } return; } - if (left.kind === 90) { + if (left.kind === 91) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -13172,7 +13899,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 90 && getDeclarationKindFromSymbol(prop) !== 132) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -13184,14 +13911,14 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 153 + var left = node.kind === 155 ? node.expression : node.left; var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 90 && getDeclarationKindFromSymbol(prop) !== 132) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { return false; } else { @@ -13206,15 +13933,15 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 156 && node.parent.expression === node) { + if (node.parent.kind === 158 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); } else { - var _start = node.end - "]".length; - var _end = node.end; - grammarErrorAtPos(sourceFile, _start, _end - _start, ts.Diagnostics.Expression_expected); + var start = node.end - "]".length; + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } } var objectType = getApparentType(checkExpression(node.expression)); @@ -13229,15 +13956,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var _name = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (_name !== undefined) { - var prop = getPropertyOfType(objectType, _name); + var name_6 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_6 !== undefined) { + var prop = getPropertyOfType(objectType, name_6); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, _name, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_6, symbolToString(objectType.symbol)); return unknownType; } } @@ -13302,7 +14029,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 157) { + if (node.kind === 159) { checkExpression(node.template); } else { @@ -13327,19 +14054,19 @@ var ts; for (var _i = 0, _n = signatures.length; _i < _n; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var _parent = signature.declaration && signature.declaration.parent; + var parent_4 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && _parent === lastParent) { + if (lastParent && parent_4 === lastParent) { index++; } else { - lastParent = _parent; + lastParent = parent_4; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = _parent; + lastParent = parent_4; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -13355,7 +14082,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 171) { + if (args[i].kind === 173) { return i; } } @@ -13365,11 +14092,11 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 157) { + if (node.kind === 159) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 169) { + if (tagExpression.template.kind === 171) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -13384,7 +14111,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 156); + ts.Debug.assert(callExpression.kind === 158); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -13423,16 +14150,23 @@ var ts; }); return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature, args, excludeArgument) { + function inferTypeArguments(signature, args, excludeArgument, context) { var typeParameters = signature.typeParameters; - var context = createInferenceContext(typeParameters, false); var inferenceMapper = createInferenceMapper(context); + for (var i = 0; i < typeParameters.length; i++) { + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 172) { - var paramType = getTypeAtPosition(signature, arg.kind === 171 ? -1 : i); + if (arg.kind !== 174) { + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 157) { + if (i === 0 && args[i].parent.kind === 159) { argType = globalTemplateStringsArrayType; } else { @@ -13443,22 +14177,15 @@ var ts; } } if (excludeArgument) { - for (var _i = 0; _i < args.length; _i++) { - if (excludeArgument[_i] === false) { - var _arg = args[_i]; - var _paramType = getTypeAtPosition(signature, _arg.kind === 171 ? -1 : _i); - inferTypes(context, checkExpressionWithContextualType(_arg, _paramType, inferenceMapper), _paramType); + for (var i = 0; i < args.length; i++) { + if (excludeArgument[i] === false) { + var arg = args[i]; + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); + inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); } } } - var inferredTypes = getInferredTypes(context); - context.failedTypeParameterIndex = ts.indexOf(inferredTypes, inferenceFailureType); - for (var _i_1 = 0; _i_1 < inferredTypes.length; _i_1++) { - if (inferredTypes[_i_1] === inferenceFailureType) { - inferredTypes[_i_1] = unknownType; - } - } - return context; + getInferredTypes(context); } function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { var typeParameters = signature.typeParameters; @@ -13479,9 +14206,9 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 172) { - var paramType = getTypeAtPosition(signature, arg.kind === 171 ? -1 : i); - var argType = i === 0 && node.kind === 157 ? globalTemplateStringsArrayType : + if (arg.kind !== 174) { + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); + var argType = i === 0 && node.kind === 159 ? globalTemplateStringsArrayType : arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { @@ -13493,10 +14220,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 157) { + if (node.kind === 159) { var template = node.template; args = [template]; - if (template.kind === 169) { + if (template.kind === 171) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -13508,8 +14235,8 @@ var ts; return args; } function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 90) { - var containingClass = ts.getAncestor(callExpression, 196); + if (callExpression.expression.kind === 91) { + var containingClass = ts.getAncestor(callExpression, 198); var baseClassTypeNode = containingClass && ts.getClassBaseTypeNode(containingClass); return baseClassTypeNode && baseClassTypeNode.typeArguments; } @@ -13518,11 +14245,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 157; + var isTaggedTemplate = node.kind === 159; var typeArguments; if (!isTaggedTemplate) { typeArguments = getEffectiveTypeArguments(node); - if (node.expression.kind !== 90) { + if (node.expression.kind !== 91) { ts.forEach(typeArguments, checkSourceElement); } } @@ -13586,56 +14313,57 @@ var ts; } return resolveErrorCall(node); function chooseOverload(candidates, relation) { - for (var _a = 0, _b = candidates.length; _a < _b; _a++) { - var current = candidates[_a]; - if (!hasCorrectArity(node, args, current)) { + for (var _i = 0, _n = candidates.length; _i < _n; _i++) { + var originalCandidate = candidates[_i]; + if (!hasCorrectArity(node, args, originalCandidate)) { continue; } - var originalCandidate = current; - var inferenceResult = void 0; - var _candidate = void 0; + var candidate = void 0; var typeArgumentsAreValid = void 0; + var inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, false) + : undefined; while (true) { - _candidate = originalCandidate; - if (_candidate.typeParameters) { + candidate = originalCandidate; + if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = new Array(_candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(_candidate, typeArguments, typeArgumentTypes, false); + typeArgumentTypes = new Array(candidate.typeParameters.length); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { - inferenceResult = inferTypeArguments(_candidate, args, excludeArgument); - typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0; - typeArgumentTypes = inferenceResult.inferredTypes; + inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; } if (!typeArgumentsAreValid) { break; } - _candidate = getSignatureInstantiation(_candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, _candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; if (index < 0) { - return _candidate; + return candidate; } excludeArgument[index] = false; } if (originalCandidate.typeParameters) { - var instantiatedCandidate = _candidate; + var instantiatedCandidate = candidate; if (typeArgumentsAreValid) { candidateForArgumentError = instantiatedCandidate; } else { candidateForTypeArgumentError = originalCandidate; if (!typeArguments) { - resultOfFailedInference = inferenceResult; + resultOfFailedInference = inferenceContext; } } } else { - ts.Debug.assert(originalCandidate === _candidate); + ts.Debug.assert(originalCandidate === candidate); candidateForArgumentError = originalCandidate; } } @@ -13643,7 +14371,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 90) { + if (node.expression.kind === 91) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1), candidatesOutArray); @@ -13727,13 +14455,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 155) { + if (node.kind === 157) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 156) { + else if (node.kind === 158) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 157) { + else if (node.kind === 159) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -13745,15 +14473,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 90) { + if (node.expression.kind === 91) { return voidType; } - if (node.kind === 156) { + if (node.kind === 158) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 133 && - declaration.kind !== 137 && - declaration.kind !== 141) { + declaration.kind !== 135 && + declaration.kind !== 139 && + declaration.kind !== 143) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -13794,9 +14522,9 @@ var ts; links.type = instantiateType(getTypeAtPosition(context, i), mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - var _parameter = signature.parameters[signature.parameters.length - 1]; - var _links = getSymbolLinks(_parameter); - _links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); + var parameter = signature.parameters[signature.parameters.length - 1]; + var links = getSymbolLinks(parameter); + links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); } } function getReturnTypeFromBody(func, contextualMapper) { @@ -13805,7 +14533,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 174) { + if (func.body.kind !== 176) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -13843,7 +14571,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 190); + return (body.statements.length === 1) && (body.statements[0].kind === 192); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -13852,7 +14580,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 174) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 176) { return; } var bodyBlock = func.body; @@ -13865,9 +14593,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 160) { + if (!hasGrammarError && node.kind === 162) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -13895,19 +14623,19 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 132 && node.kind !== 131) { + if (produceDiagnostics && node.kind !== 134 && node.kind !== 133) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } if (node.body) { - if (node.body.kind === 174) { + if (node.body.kind === 176) { checkSourceElement(node.body); } else { @@ -13933,17 +14661,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 64: { + case 65: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 153: { - var _symbol = findSymbol(n); - return !_symbol || _symbol === unknownSymbol || (_symbol.flags & ~8) !== 0; + case 155: { + var symbol = findSymbol(n); + return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 154: + case 156: return true; - case 159: + case 161: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -13951,27 +14679,40 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 64: - case 153: { + case 65: + case 155: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 154: { + case 156: { var index = n.argumentExpression; - var _symbol = findSymbol(n.expression); - if (_symbol && index && index.kind === 8) { - var _name = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(_symbol), _name); + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 8) { + var name_7 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_7); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 8192) !== 0; } return false; } - case 159: + case 161: return isConstVariableReference(n.expression); default: return false; } } + function isImportedNameFromExternalModule(n) { + switch (n.kind) { + case 156: + case 155: { + var symbol = findSymbol(n.expression); + return symbol && symbol.flags & 8388608 && isExternalModuleSymbol(resolveAlias(symbol)); + } + case 161: + return isImportedNameFromExternalModule(n.expression); + default: + return false; + } + } if (!isReferenceOrErrorExpression(n)) { error(n, invalidReferenceMessage); return false; @@ -13980,10 +14721,13 @@ var ts; error(n, constantVariableMessage); return false; } + if (isImportedNameFromExternalModule(n)) { + error(n, invalidReferenceMessage); + } return true; } function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 && node.expression.kind === 64) { + if (node.parserContextFlags & 1 && node.expression.kind === 65) { grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); } var operandType = checkExpression(node.expression); @@ -14091,17 +14835,17 @@ var ts; var properties = node.properties; for (var _i = 0, _n = properties.length; _i < _n; _i++) { var p = properties[_i]; - if (p.kind === 218 || p.kind === 219) { - var _name = p.name; + if (p.kind === 221 || p.kind === 222) { + var name_8 = p.name; var type = sourceType.flags & 1 ? sourceType : - getTypeOfPropertyOfType(sourceType, _name.text) || - isNumericLiteralName(_name.text) && getIndexTypeOfType(sourceType, 1) || + getTypeOfPropertyOfType(sourceType, name_8.text) || + isNumericLiteralName(name_8.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || _name, type); + checkDestructuringAssignment(p.initializer || name_8, type); } else { - error(_name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(_name)); + error(name_8, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_8)); } } else { @@ -14118,8 +14862,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 172) { - if (e.kind !== 171) { + if (e.kind !== 174) { + if (e.kind !== 173) { var propName = "" + i; var type = sourceType.flags & 1 ? sourceType : isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) : @@ -14149,14 +14893,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 167 && target.operatorToken.kind === 52) { + if (target.kind === 169 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 152) { + if (target.kind === 154) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 151) { + if (target.kind === 153) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -14173,32 +14917,32 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operatorToken.kind; - if (operator === 52 && (node.left.kind === 152 || node.left.kind === 151)) { + if (operator === 53 && (node.left.kind === 154 || node.left.kind === 153)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { case 35: - case 55: - case 36: case 56: - case 37: + case 36: case 57: - case 34: - case 54: - case 40: + case 37: case 58: - case 41: + case 34: + case 55: + case 40: case 59: - case 42: + case 41: case 60: - case 44: - case 62: - case 45: - case 63: - case 43: + case 42: case 61: + case 44: + case 63: + case 45: + case 64: + case 43: + case 62: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -14218,7 +14962,7 @@ var ts; } return numberType; case 33: - case 53: + case 54: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -14242,7 +14986,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 53) { + if (operator === 54) { checkAssignmentOperator(resultType); } return resultType; @@ -14261,15 +15005,15 @@ var ts; reportOperatorError(); } return booleanType; - case 86: + case 87: return checkInstanceOfExpression(node, leftType, rightType); - case 85: + case 86: return checkInExpression(node, leftType, rightType); case 48: return rightType; case 49: return getUnionType([leftType, rightType]); - case 52: + case 53: checkAssignmentOperator(rightType); return rightType; case 23: @@ -14288,20 +15032,20 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 44: - case 62: + case 63: return 49; case 45: - case 63: + case 64: return 31; case 43: - case 61: + case 62: return 48; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 52 && operator <= 63) { + if (produceDiagnostics && operator >= 53 && operator <= 64) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -14347,14 +15091,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -14380,7 +15124,7 @@ var ts; } function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 125) { + if (node.kind == 126) { type = checkQualifiedName(node); } else { @@ -14388,9 +15132,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 153 && node.parent.expression === node) || - (node.parent.kind === 154 && node.parent.expression === node) || - ((node.kind === 64 || node.kind === 125) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 155 && node.parent.expression === node) || + (node.parent.kind === 156 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 126) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -14403,65 +15147,65 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 64: + case 65: return checkIdentifier(node); - case 92: + case 93: return checkThisExpression(node); - case 90: + case 91: return checkSuperExpression(node); - case 88: + case 89: return nullType; - case 94: - case 79: + case 95: + case 80: return booleanType; case 7: return checkNumericLiteral(node); - case 169: + case 171: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 151: - return checkArrayLiteral(node, contextualMapper); - case 152: - return checkObjectLiteral(node, contextualMapper); case 153: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 154: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 155: + return checkPropertyAccessExpression(node); case 156: - return checkCallExpression(node); + return checkIndexedAccess(node); case 157: - return checkTaggedTemplateExpression(node); case 158: - return checkTypeAssertion(node); + return checkCallExpression(node); case 159: - return checkExpression(node.expression, contextualMapper); + return checkTaggedTemplateExpression(node); case 160: + return checkTypeAssertion(node); case 161: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 163: - return checkTypeOfExpression(node); + return checkExpression(node.expression, contextualMapper); case 162: - return checkDeleteExpression(node); - case 164: - return checkVoidExpression(node); + case 163: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 165: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 164: + return checkDeleteExpression(node); case 166: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 167: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 168: - return checkConditionalExpression(node, contextualMapper); - case 171: - return checkSpreadElementExpression(node, contextualMapper); - case 172: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 169: + return checkBinaryExpression(node, contextualMapper); case 170: + return checkConditionalExpression(node, contextualMapper); + case 173: + return checkSpreadElementExpression(node, contextualMapper); + case 174: + return undefinedType; + case 172: checkYieldExpression(node); return unknownType; } @@ -14478,12 +15222,18 @@ var ts; } } function checkParameter(node) { - checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + // Grammar checking + // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the + // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code + // or if its FunctionBody is strict code(11.1.5). + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 133 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 135 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -14497,12 +15247,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 138) { + if (node.kind === 140) { checkGrammarIndexSignature(node); } - else if (node.kind === 140 || node.kind === 195 || node.kind === 141 || - node.kind === 136 || node.kind === 133 || - node.kind === 137) { + else if (node.kind === 142 || node.kind === 197 || node.kind === 143 || + node.kind === 138 || node.kind === 135 || + node.kind === 139) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -14514,10 +15264,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 137: + case 139: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 136: + case 138: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -14526,7 +15276,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 197) { + if (node.kind === 199) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14541,7 +15291,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 120: + case 121: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -14549,7 +15299,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 118: + case 119: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -14563,7 +15313,7 @@ var ts; } } function checkPropertyDeclaration(node) { - checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); } function checkMethodDeclaration(node) { @@ -14586,30 +15336,30 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 155 && n.expression.kind === 90; + return n.kind === 157 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 160: - case 195: - case 161: - case 152: return false; + case 162: + case 197: + case 163: + case 154: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 92) { + if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 160 && n.kind !== 195) { + else if (n.kind !== 162 && n.kind !== 197) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 130 && + return n.kind === 132 && !(n.flags & 128) && !!n.initializer; } @@ -14619,7 +15369,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 177 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 179 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -14635,13 +15385,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 134) { + if (node.kind === 136) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 134 ? 135 : 134; + var otherKind = node.kind === 136 ? 137 : 136; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -14660,6 +15410,9 @@ var ts; } checkFunctionLikeDeclaration(node); } + function checkMissingDeclaration(node) { + checkDecorators(node); + } function checkTypeReference(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReferenceNode(node); @@ -14715,9 +15468,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 197) { - ts.Debug.assert(signatureDeclarationNode.kind === 136 || signatureDeclarationNode.kind === 137); - var signatureKind = signatureDeclarationNode.kind === 136 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 199) { + ts.Debug.assert(signatureDeclarationNode.kind === 138 || signatureDeclarationNode.kind === 139); + var signatureKind = signatureDeclarationNode.kind === 138 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -14735,7 +15488,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 197 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 199 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -14806,16 +15559,16 @@ var ts; }); if (subsequentNode) { if (subsequentNode.kind === node.kind) { - var _errorNode = subsequentNode.name || subsequentNode; + var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 132 || node.kind === 131); + ts.Debug.assert(node.kind === 134 || node.kind === 133); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; - error(_errorNode, diagnostic); + error(errorNode_1, diagnostic); return; } else if (ts.nodeIsPresent(subsequentNode.body)) { - error(_errorNode, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); + error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); return; } } @@ -14835,11 +15588,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 197 || node.parent.kind === 143 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 199 || node.parent.kind === 145 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 195 || node.kind === 132 || node.kind === 131 || node.kind === 133) { + if (node.kind === 197 || node.kind === 134 || node.kind === 133 || node.kind === 135) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -14936,16 +15689,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 197: + case 199: return 2097152; - case 200: + case 202: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 196: - case 199: + case 198: + case 201: return 2097152 | 1048576; - case 203: + case 205: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -14955,6 +15708,49 @@ var ts; } } } + function checkDecorator(node) { + var expression = node.expression; + var exprType = checkExpression(expression); + switch (node.parent.kind) { + case 198: + var classSymbol = getSymbolOfNode(node.parent); + var classConstructorType = getTypeOfSymbol(classSymbol); + var classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + checkTypeAssignableTo(exprType, classDecoratorType, node); + break; + case 132: + checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + break; + case 134: + case 136: + case 137: + var methodType = getTypeOfNode(node.parent); + var methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + checkTypeAssignableTo(exprType, methodDecoratorType, node); + break; + case 129: + checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + break; + } + } + function checkDecorators(node) { + if (!node.decorators) { + return; + } + switch (node.kind) { + case 198: + case 134: + case 136: + case 137: + case 132: + case 129: + emitDecorate = true; + break; + default: + return; + } + ts.forEach(node.decorators, checkDecorator); + } function checkFunctionDeclaration(node) { if (produceDiagnostics) { checkFunctionLikeDeclaration(node) || @@ -14967,8 +15763,9 @@ var ts; } } function checkFunctionLikeDeclaration(node) { + checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 126) { + if (node.name && node.name.kind === 127) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -14993,11 +15790,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 174) { + if (node.kind === 176) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 201) { + if (ts.isFunctionBlock(node) || node.kind === 203) { checkFunctionExpressionBodies(node); } } @@ -15015,19 +15812,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 130 || - node.kind === 129 || - node.kind === 132 || + if (node.kind === 132 || node.kind === 131 || node.kind === 134 || - node.kind === 135) { + node.kind === 133 || + node.kind === 136 || + node.kind === 137) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = getRootDeclaration(node); - if (root.kind === 128 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 129 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -15041,8 +15838,8 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var _isDeclaration = node.kind !== 64; - if (_isDeclaration) { + var isDeclaration_1 = node.kind !== 65; + if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { @@ -15057,13 +15854,13 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 196); + var enclosingClass = ts.getAncestor(node, 198); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } if (ts.getClassBaseTypeNode(enclosingClass)) { - var _isDeclaration = node.kind !== 64; - if (_isDeclaration) { + var isDeclaration_2 = node.kind !== 65; + if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -15075,56 +15872,65 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 200 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 202 && ts.getModuleInstanceState(node) !== 1) { return; } - var _parent = getDeclarationContainer(node); - if (_parent.kind === 221 && ts.isExternalModule(_parent)) { + var parent = getDeclarationContainer(node); + if (parent.kind === 224 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkVarDeclaredNamesNotShadowed(node) { - if (node.initializer && (ts.getCombinedNodeFlags(node) & 12288) === 0) { - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); - if (localDeclarationSymbol && - localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 194); - var container = varDeclList.parent.kind === 175 && - varDeclList.parent.parent; - var namesShareScope = container && - (container.kind === 174 && ts.isFunctionLike(container.parent) || - (container.kind === 201 && container.kind === 200) || - container.kind === 221); - if (!namesShareScope) { - var _name = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, _name, _name); - } + // - ScriptBody : StatementList + // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList + // also occurs in the VarDeclaredNames of StatementList. + if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || isParameterDeclaration(node)) { + return; + } + if (node.kind === 195 && !node.initializer) { + return; + } + var symbol = getSymbolOfNode(node); + if (symbol.flags & 1) { + var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); + if (localDeclarationSymbol && + localDeclarationSymbol !== symbol && + localDeclarationSymbol.flags & 2) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 196); + var container = varDeclList.parent.kind === 177 && varDeclList.parent.parent + ? varDeclList.parent.parent + : undefined; + var namesShareScope = container && + (container.kind === 176 && ts.isFunctionLike(container.parent) || + container.kind === 203 || + container.kind === 202 || + container.kind === 224); + if (!namesShareScope) { + var name_9 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_9, name_9); } } } } } function isParameterDeclaration(node) { - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent.parent; } - return node.kind === 128; + return node.kind === 129; } function checkParameterInitializer(node) { - if (getRootDeclaration(node).kind !== 128) { + if (getRootDeclaration(node).kind !== 129) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 64) { + if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 128) { + if (referencedSymbol.valueDeclaration.kind === 129) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -15142,8 +15948,9 @@ var ts; } } function checkVariableLikeDeclaration(node) { + checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -15152,7 +15959,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && getRootDeclaration(node).kind === 128 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && getRootDeclaration(node).kind === 129 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -15180,9 +15987,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 130 && node.kind !== 129) { + if (node.kind !== 132 && node.kind !== 131) { checkExportsOnMergedDeclarations(node); - if (node.kind === 193 || node.kind === 150) { + if (node.kind === 195 || node.kind === 152) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -15199,7 +16006,7 @@ var ts; return checkVariableLikeDeclaration(node); } function checkVariableStatement(node) { - checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + checkGrammarDecorators(node) || checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) { @@ -15211,7 +16018,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 174 || node.kind === 152) { + if (node.kind === 176 || node.kind === 154) { return true; } node = node.parent; @@ -15239,12 +16046,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 194) { + if (node.initializer && node.initializer.kind == 196) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -15259,13 +16066,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 151 || varExpr.kind === 152) { + if (varExpr.kind === 153 || varExpr.kind === 154) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -15280,7 +16087,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -15290,7 +16097,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 151 || varExpr.kind === 152) { + if (varExpr.kind === 153 || varExpr.kind === 154) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!allConstituentTypesHaveKind(leftType, 1 | 258)) { @@ -15330,6 +16137,31 @@ var ts; } return iteratedType; function getIteratedType(iterable, expressionForError) { + // We want to treat type as an iterable, and get the type it is an iterable of. The iterable + // must have the following structure (annotated with the names of the variables below): + // + // { // iterable + // [Symbol.iterator]: { // iteratorFunction + // (): { // iterator + // next: { // iteratorNextFunction + // (): { // iteratorNextResult + // value: T // iteratorNextValue + // } + // } + // } + // } + // } + // + // T is the type we are after. At every level that involves analyzing return types + // of signatures, we union the return types of all the signatures. + // + // Another thing to note is that at any step of this process, we could run into a dead end, + // meaning either the property is missing, or we run into the anyType. If either of these things + // happens, we return undefined to signal that we could not find the iterated type. If a property + // is missing, and the previous step did not result in 'any', then we also give an error if the + // caller requested it. Then the caller can decide what to do in the case where there is no iterated + // type. This is different from returning anyType, because that would signify that we have matched the + // whole pattern and that T (above) is 'any'. if (allConstituentTypesHaveKind(iterable, 1)) { return undefined; } @@ -15409,7 +16241,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 134 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 135))); + return !!(node.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 137))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -15423,11 +16255,11 @@ var ts; if (func) { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); var exprType = checkExpressionCached(node.expression); - if (func.kind === 135) { + if (func.kind === 137) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - if (func.kind === 133) { + if (func.kind === 135) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -15454,7 +16286,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 215 && !hasDuplicateDefaultClause) { + if (clause.kind === 218 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -15466,7 +16298,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 214) { + if (produceDiagnostics && clause.kind === 217) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -15483,7 +16315,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 189 && current.label.text === node.label.text) { + if (current.kind === 191 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -15509,7 +16341,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 64) { + if (catchClause.variableDeclaration.name.kind !== 65) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -15547,7 +16379,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 196) { + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 198) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members, _n = _a.length; _i < _n; _i++) { var member = _a[_i]; @@ -15577,22 +16409,22 @@ var ts; if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { return; } - var _errorNode; - if (prop.valueDeclaration.name.kind === 126 || prop.parent === containingType.symbol) { - _errorNode = prop.valueDeclaration; + var errorNode; + if (prop.valueDeclaration.name.kind === 127 || prop.parent === containingType.symbol) { + errorNode = prop.valueDeclaration; } else if (indexDeclaration) { - _errorNode = indexDeclaration; + errorNode = indexDeclaration; } else if (containingType.flags & 2048) { var someBaseClassHasBothPropertyAndIndexer = ts.forEach(containingType.baseTypes, function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - _errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; } - if (_errorNode && !isTypeAssignableTo(propertyType, indexType)) { + if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(_errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); } } } @@ -15624,6 +16456,7 @@ var ts; } function checkClassDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); + checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); @@ -15680,6 +16513,19 @@ var ts; return s.flags & 16777216 ? getSymbolLinks(s).target : s; } function checkKindsOfPropertyMemberOverrides(type, baseType) { + // TypeScript 1.0 spec (April 2014): 8.2.3 + // A derived class inherits all members from its base class it doesn't override. + // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. + // Both public and private property members are inherited, but only public property members can be overridden. + // A property member in a derived class is said to override a property member in a base class + // when the derived class property member has the same name and kind(instance or static) + // as the base class property member. + // The type of an overriding property member must be assignable(section 3.8.4) + // to the type of the overridden property member, or otherwise a compile - time error occurs. + // Base class instance member functions can be overridden by derived class instance member functions, + // but not by other kinds of members. + // Base class instance member variables and accessors can be overridden by + // derived class instance member variables and accessors, but not by other kinds of members. var baseProperties = getPropertiesOfObjectType(baseType); for (var _i = 0, _n = baseProperties.length; _i < _n; _i++) { var baseProperty = baseProperties[_i]; @@ -15724,7 +16570,7 @@ var ts; } } function isAccessor(kind) { - return kind === 134 || kind === 135; + return kind === 136 || kind === 137; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -15783,13 +16629,13 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 197); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 199); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15812,25 +16658,25 @@ var ts; } } function checkTypeAliasDeclaration(node) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); } function computeEnumMemberValues(node) { - var _nodeLinks = getNodeLinks(node); - if (!(_nodeLinks.flags & 128)) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 128)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 126 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 127 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); + autoValue = getConstantValueForEnumMemberInitializer(initializer); if (autoValue === undefined) { if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); @@ -15855,13 +16701,13 @@ var ts; getNodeLinks(member).enumMemberValue = autoValue++; } }); - _nodeLinks.flags |= 128; + nodeLinks.flags |= 128; } - function getConstantValueForEnumMemberInitializer(initializer, enumIsConst) { + function getConstantValueForEnumMemberInitializer(initializer) { return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 165: + case 167: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -15869,13 +16715,10 @@ var ts; switch (e.operator) { case 33: return value; case 34: return -value; - case 47: return enumIsConst ? ~value : undefined; + case 47: return ~value; } return undefined; - case 167: - if (!enumIsConst) { - return undefined; - } + case 169: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -15900,43 +16743,54 @@ var ts; return undefined; case 7: return +e.text; - case 159: - return enumIsConst ? evalConstant(e.expression) : undefined; - case 64: - case 154: - case 153: - if (!enumIsConst) { - return undefined; - } + case 161: + return evalConstant(e.expression); + case 65: + case 156: + case 155: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var _enumType; + var enumType; var propertyName; - if (e.kind === 64) { - _enumType = currentType; + if (e.kind === 65) { + enumType = currentType; propertyName = e.text; } else { - if (e.kind === 154) { + var expression; + if (e.kind === 156) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; } - _enumType = getTypeOfNode(e.expression); + expression = e.expression; propertyName = e.argumentExpression.text; } else { - _enumType = getTypeOfNode(e.expression); + expression = e.expression; propertyName = e.name.text; } - if (_enumType !== currentType) { + var current = expression; + while (current) { + if (current.kind === 65) { + break; + } + else if (current.kind === 155) { + current = current.expression; + } + else { + return undefined; + } + } + enumType = checkExpression(expression); + if (!(enumType.symbol && (enumType.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(_enumType, propertyName); + var property = getPropertyOfObjectType(enumType, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -15956,7 +16810,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -15975,7 +16829,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 199) { + if (declaration.kind !== 201) { return false; } var enumDeclaration = declaration; @@ -15998,7 +16852,7 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 196 || (declaration.kind === 195 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 198 || (declaration.kind === 197 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -16006,7 +16860,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarModifiers(node)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -16041,7 +16895,7 @@ var ts; checkSourceElement(node.body); } function getFirstIdentifier(node) { - while (node.kind === 125) { + while (node.kind === 126) { node = node.left; } return node; @@ -16052,9 +16906,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 201 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 221 && !inAmbientExternalModule) { - error(moduleName, node.kind === 210 ? + var inAmbientExternalModule = node.parent.kind === 203 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 224 && !inAmbientExternalModule) { + error(moduleName, node.kind === 212 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module : ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); return false; @@ -16073,7 +16927,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 212 ? + var message = node.kind === 214 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -16086,7 +16940,7 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -16096,7 +16950,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { checkImportBinding(importClause.namedBindings); } else { @@ -16107,7 +16961,7 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -16127,15 +16981,30 @@ var ts; } } } + else { + if (languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + } + } } } function checkExportDeclaration(node) { - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); + var inAmbientExternalModule = node.parent.kind === 203 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 224 && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + } + } + else { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, ts.Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } } } } @@ -16146,67 +17015,58 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 221 ? node.parent : node.parent.parent; - if (container.kind === 200 && container.name.kind === 64) { + var container = node.parent.kind === 224 ? node.parent : node.parent.parent; + if (container.kind === 202 && container.name.kind === 65) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); return; } - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 64) { - markExportAsReferenced(node); + if (node.expression) { + if (node.expression.kind === 65) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } } - else { - checkExpressionCached(node.expression); + if (node.type) { + checkSourceElement(node.type); + if (!ts.isInAmbientContext(node)) { + grammarErrorOnFirstToken(node.type, ts.Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration); + } } checkExternalModuleExports(container); + if (node.isExportEquals && languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } } function getModuleStatements(node) { - if (node.kind === 221) { + if (node.kind === 224) { return node.statements; } - if (node.kind === 200 && node.body.kind === 201) { + if (node.kind === 202 && node.body.kind === 203) { return node.body.statements; } return emptyArray; } function hasExportedMembers(moduleSymbol) { - var declarations = moduleSymbol.declarations; - for (var _i = 0, _n = declarations.length; _i < _n; _i++) { - var current = declarations[_i]; - var statements = getModuleStatements(current); - for (var _a = 0, _b = statements.length; _a < _b; _a++) { - var node = statements[_a]; - if (node.kind === 210) { - var exportClause = node.exportClause; - if (!exportClause) { - return true; - } - var specifiers = exportClause.elements; - for (var _c = 0, _d = specifiers.length; _c < _d; _c++) { - var specifier = specifiers[_c]; - if (!(specifier.propertyName && specifier.name && specifier.name.text === "default")) { - return true; - } - } - } - else if (node.kind !== 209 && node.flags & 1 && !(node.flags & 256)) { - return true; - } + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; } } + return false; } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - if (hasExportedMembers(moduleSymbol)) { - var declaration = getDeclarationOfAliasSymbol(defaultSymbol) || defaultSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } + var exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } links.exportsChecked = true; } @@ -16215,162 +17075,162 @@ var ts; if (!node) return; switch (node.kind) { - case 127: - return checkTypeParameter(node); case 128: - return checkParameter(node); - case 130: + return checkTypeParameter(node); case 129: - return checkPropertyDeclaration(node); - case 140: - case 141: - case 136: - case 137: - return checkSignatureDeclaration(node); - case 138: - return checkSignatureDeclaration(node); + return checkParameter(node); case 132: case 131: - return checkMethodDeclaration(node); - case 133: - return checkConstructorDeclaration(node); - case 134: - case 135: - return checkAccessorDeclaration(node); - case 139: - return checkTypeReference(node); + return checkPropertyDeclaration(node); case 142: - return checkTypeQuery(node); case 143: - return checkTypeLiteral(node); + case 138: + case 139: + return checkSignatureDeclaration(node); + case 140: + return checkSignatureDeclaration(node); + case 134: + case 133: + return checkMethodDeclaration(node); + case 135: + return checkConstructorDeclaration(node); + case 136: + case 137: + return checkAccessorDeclaration(node); + case 141: + return checkTypeReference(node); case 144: - return checkArrayType(node); + return checkTypeQuery(node); case 145: - return checkTupleType(node); + return checkTypeLiteral(node); case 146: - return checkUnionType(node); + return checkArrayType(node); case 147: + return checkTupleType(node); + case 148: + return checkUnionType(node); + case 149: return checkSourceElement(node.type); - case 195: - return checkFunctionDeclaration(node); - case 174: - case 201: - return checkBlock(node); - case 175: - return checkVariableStatement(node); - case 177: - return checkExpressionStatement(node); - case 178: - return checkIfStatement(node); - case 179: - return checkDoStatement(node); - case 180: - return checkWhileStatement(node); - case 181: - return checkForStatement(node); - case 182: - return checkForInStatement(node); - case 183: - return checkForOfStatement(node); - case 184: - case 185: - return checkBreakOrContinueStatement(node); - case 186: - return checkReturnStatement(node); - case 187: - return checkWithStatement(node); - case 188: - return checkSwitchStatement(node); - case 189: - return checkLabeledStatement(node); - case 190: - return checkThrowStatement(node); - case 191: - return checkTryStatement(node); - case 193: - return checkVariableDeclaration(node); - case 150: - return checkBindingElement(node); - case 196: - return checkClassDeclaration(node); case 197: - return checkInterfaceDeclaration(node); - case 198: - return checkTypeAliasDeclaration(node); - case 199: - return checkEnumDeclaration(node); - case 200: - return checkModuleDeclaration(node); - case 204: - return checkImportDeclaration(node); - case 203: - return checkImportEqualsDeclaration(node); - case 210: - return checkExportDeclaration(node); - case 209: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 176: - checkGrammarStatementInAmbientContext(node); - return; + case 203: + return checkBlock(node); + case 177: + return checkVariableStatement(node); + case 179: + return checkExpressionStatement(node); + case 180: + return checkIfStatement(node); + case 181: + return checkDoStatement(node); + case 182: + return checkWhileStatement(node); + case 183: + return checkForStatement(node); + case 184: + return checkForInStatement(node); + case 185: + return checkForOfStatement(node); + case 186: + case 187: + return checkBreakOrContinueStatement(node); + case 188: + return checkReturnStatement(node); + case 189: + return checkWithStatement(node); + case 190: + return checkSwitchStatement(node); + case 191: + return checkLabeledStatement(node); case 192: + return checkThrowStatement(node); + case 193: + return checkTryStatement(node); + case 195: + return checkVariableDeclaration(node); + case 152: + return checkBindingElement(node); + case 198: + return checkClassDeclaration(node); + case 199: + return checkInterfaceDeclaration(node); + case 200: + return checkTypeAliasDeclaration(node); + case 201: + return checkEnumDeclaration(node); + case 202: + return checkModuleDeclaration(node); + case 206: + return checkImportDeclaration(node); + case 205: + return checkImportEqualsDeclaration(node); + case 212: + return checkExportDeclaration(node); + case 211: + return checkExportAssignment(node); + case 178: checkGrammarStatementInAmbientContext(node); return; + case 194: + checkGrammarStatementInAmbientContext(node); + return; + case 215: + return checkMissingDeclaration(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 160: - case 161: + case 162: + case 163: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 132: - case 131: + case 134: + case 133: ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 133: - case 134: case 135: - case 195: + case 136: + case 137: + case 197: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 187: + case 189: checkFunctionExpressionBodies(node.expression); break; - case 128: - case 130: case 129: - case 148: - case 149: + case 132: + case 131: case 150: case 151: case 152: - case 218: case 153: case 154: + case 221: case 155: case 156: case 157: - case 169: - case 173: case 158: case 159: - case 163: - case 164: - case 162: + case 171: + case 175: + case 160: + case 161: case 165: case 166: + case 164: case 167: case 168: - case 171: - case 174: - case 201: - case 175: + case 169: + case 170: + case 173: + case 176: + case 203: case 177: - case 178: case 179: case 180: case 181: @@ -16379,21 +17239,23 @@ var ts; case 184: case 185: case 186: + case 187: case 188: - case 202: - case 214: - case 215: - case 189: case 190: - case 191: + case 204: case 217: + case 218: + case 191: + case 192: case 193: - case 194: - case 196: - case 199: case 220: - case 209: - case 221: + case 195: + case 196: + case 198: + case 201: + case 223: + case 211: + case 224: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -16421,6 +17283,9 @@ var ts; if (emitExtends) { links.flags |= 8; } + if (emitDecorate) { + links.flags |= 512; + } links.flags |= 1; } } @@ -16445,7 +17310,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 187 && node.parent.statement === node) { + if (node.parent.kind === 189 && node.parent.statement === node) { return true; } node = node.parent; @@ -16456,6 +17321,44 @@ var ts; function getSymbolsInScope(location, meaning) { var symbols = {}; var memberFlags = 0; + if (isInsideWithStatementBody(location)) { + return []; + } + populateSymbols(); + return symbolsToArray(symbols); + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + switch (location.kind) { + case 224: + if (!ts.isExternalModule(location)) { + break; + } + case 202: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); + break; + case 201: + copySymbols(getSymbolOfNode(location).exports, meaning & 8); + break; + case 198: + case 199: + if (!(memberFlags & 128)) { + copySymbols(getSymbolOfNode(location).members, meaning & 793056); + } + break; + case 162: + if (location.name) { + copySymbol(location.symbol, meaning); + } + break; + } + memberFlags = location.flags; + location = location.parent; + } + copySymbols(globals, meaning); + } function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; @@ -16481,22 +17384,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 221: + case 224: if (!ts.isExternalModule(location)) break; - case 200: + case 202: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 199: + case 201: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 196: - case 197: + case 198: + case 199: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 160: + case 162: if (location.name) { copySymbol(location.symbol, meaning); } @@ -16506,97 +17409,97 @@ var ts; location = location.parent; } copySymbols(globals, meaning); - return ts.mapToArray(symbols); + return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 64 && + return name.kind == 65 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 127: - case 196: - case 197: + case 128: case 198: case 199: + case 200: + case 201: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 125) + while (node.parent && node.parent.kind === 126) node = node.parent; - return node.parent && node.parent.kind === 139; + return node.parent && node.parent.kind === 141; } function isTypeNode(node) { - if (139 <= node.kind && node.kind <= 147) { + if (141 <= node.kind && node.kind <= 149) { return true; } switch (node.kind) { - case 111: - case 118: - case 120: case 112: + case 119: case 121: + case 113: + case 122: return true; - case 98: - return node.parent.kind !== 164; + case 99: + return node.parent.kind !== 166; case 8: - return node.parent.kind === 128; - case 64: - if (node.parent.kind === 125 && node.parent.right === node) { + return node.parent.kind === 129; + case 65: + if (node.parent.kind === 126 && node.parent.right === node) { node = node.parent; } - case 125: - ts.Debug.assert(node.kind === 64 || node.kind === 125, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); - var _parent = node.parent; - if (_parent.kind === 142) { + case 126: + ts.Debug.assert(node.kind === 65 || node.kind === 126, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + var parent_5 = node.parent; + if (parent_5.kind === 144) { return false; } - if (139 <= _parent.kind && _parent.kind <= 147) { + if (141 <= parent_5.kind && parent_5.kind <= 149) { return true; } - switch (_parent.kind) { - case 127: - return node === _parent.constraint; - case 130: - case 129: + switch (parent_5.kind) { case 128: - case 193: - return node === _parent.type; - case 195: - case 160: - case 161: - case 133: + return node === parent_5.constraint; case 132: case 131: - case 134: + case 129: + case 195: + return node === parent_5.type; + case 197: + case 162: + case 163: case 135: - return node === _parent.type; + case 134: + case 133: case 136: case 137: + return node === parent_5.type; case 138: - return node === _parent.type; - case 158: - return node === _parent.type; - case 155: - case 156: - return _parent.typeArguments && ts.indexOf(_parent.typeArguments, node) >= 0; + case 139: + case 140: + return node === parent_5.type; + case 160: + return node === parent_5.type; case 157: + case 158: + return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; + case 159: return false; } } return false; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 125) { + while (nodeOnRightSide.parent.kind === 126) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 203) { + if (nodeOnRightSide.parent.kind === 205) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209) { + if (nodeOnRightSide.parent.kind === 211) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -16605,17 +17508,17 @@ var ts; return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 125 && node.parent.right === node) || - (node.parent.kind === 153 && node.parent.name === node); + return (node.parent.kind === 126 && node.parent.right === node) || + (node.parent.kind === 155 && node.parent.name === node); } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 209) { + if (entityName.parent.kind === 211) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 153) { + if (entityName.kind !== 155) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -16627,29 +17530,29 @@ var ts; if (ts.getFullWidth(entityName) === 0) { return undefined; } - if (entityName.kind === 64) { + if (entityName.kind === 65) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 153) { + else if (entityName.kind === 155) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 125) { - var _symbol = getNodeLinks(entityName).resolvedSymbol; - if (!_symbol) { + else if (entityName.kind === 126) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { checkQualifiedName(entityName); } return getNodeLinks(entityName).resolvedSymbol; } } else if (isTypeReferenceIdentifier(entityName)) { - var _meaning = entityName.parent.kind === 139 ? 793056 : 1536; - _meaning |= 8388608; - return resolveEntityName(entityName, _meaning); + var meaning = entityName.parent.kind === 141 ? 793056 : 1536; + meaning |= 8388608; + return resolveEntityName(entityName, meaning); } return undefined; } @@ -16660,23 +17563,23 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 64 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 209 + if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 211 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { - case 64: - case 153: - case 125: + case 65: + case 155: + case 126: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 92: - case 90: + case 93: + case 91: var type = checkExpression(node); return type.symbol; - case 113: + case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 133) { + if (constructorDeclaration && constructorDeclaration.kind === 135) { return constructorDeclaration.parent.symbol; } return undefined; @@ -16684,12 +17587,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 204 || node.parent.kind === 210) && + ((node.parent.kind === 206 || node.parent.kind === 212) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 154 && node.parent.argumentExpression === node) { + if (node.parent.kind == 156 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -16703,7 +17606,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 219) { + if (location && location.kind === 222) { return resolveEntityName(location.name, 107455); } return undefined; @@ -16723,21 +17626,21 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var _symbol = getSymbolInfo(node); - return _symbol && getDeclaredTypeOfSymbol(_symbol); + var symbol = getSymbolInfo(node); + return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - var _symbol_1 = getSymbolOfNode(node); - return getTypeOfSymbol(_symbol_1); + var symbol = getSymbolOfNode(node); + return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var _symbol_2 = getSymbolInfo(node); - return _symbol_2 && getTypeOfSymbol(_symbol_2); + var symbol = getSymbolInfo(node); + return symbol && getTypeOfSymbol(symbol); } if (isInRightSideOfImportOrExportAssignment(node)) { - var _symbol_3 = getSymbolInfo(node); - var declaredType = _symbol_3 && getDeclaredTypeOfSymbol(_symbol_3); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(_symbol_3); + var symbol = getSymbolInfo(node); + var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); + return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } return unknownType; } @@ -16762,9 +17665,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols = []; - var _name = symbol.name; + var name_10 = symbol.name; ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { - symbols.push(getPropertyOfType(t, _name)); + symbols.push(getPropertyOfType(t, name_10)); }); return symbols; } @@ -16777,160 +17680,73 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 221; + return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 224; } - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; + function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { + if (languageVersion >= 2) { + return undefined; } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } + var node = getDeclarationOfAliasSymbol(symbol); + if (node) { + if (node.kind === 207) { + return getGeneratedNameForNode(node.parent) + ".default"; } - } - return true; - } - function getGeneratedNamesForSourceFile(sourceFile) { - var links = getNodeLinks(sourceFile); - var generatedNames = links.generatedNames; - if (!generatedNames) { - generatedNames = links.generatedNames = {}; - generateNames(sourceFile); - } - return generatedNames; - function generateNames(node) { - switch (node.kind) { - case 195: - case 196: - generateNameForFunctionOrClassDeclaration(node); - break; - case 200: - generateNameForModuleOrEnum(node); - generateNames(node.body); - break; - case 199: - generateNameForModuleOrEnum(node); - break; - case 204: - generateNameForImportDeclaration(node); - break; - case 210: - generateNameForExportDeclaration(node); - break; - case 209: - generateNameForExportAssignment(node); - break; - case 221: - case 201: - ts.forEach(node.statements, generateNames); - break; - } - } - function isExistingName(name) { - return ts.hasProperty(globals, name) || ts.hasProperty(sourceFile.identifiers, name) || ts.hasProperty(generatedNames, name); - } - function makeUniqueName(baseName) { - var _name = ts.generateUniqueName(baseName, isExistingName); - return generatedNames[_name] = _name; - } - function assignGeneratedName(node, name) { - getNodeLinks(node).generatedName = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } - function generateNameForModuleOrEnum(node) { - if (node.name.kind === 64) { - var _name = node.name.text; - assignGeneratedName(node, isUniqueLocalName(_name, node) ? _name : makeUniqueName(_name)); - } - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); - } - function generateNameForImportDeclaration(node) { - if (node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 207) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression.kind !== 64) { - assignGeneratedName(node, makeUniqueName("default")); + if (node.kind === 210) { + var moduleName = getGeneratedNameForNode(node.parent.parent.parent); + var propertyName = node.propertyName || node.name; + return moduleName + "." + ts.unescapeIdentifier(propertyName.text); } } } - function getGeneratedNameForNode(node) { - var links = getNodeLinks(node); - if (!links.generatedName) { - getGeneratedNamesForSourceFile(getSourceFile(node)); - } - return links.generatedName; - } - function getLocalNameOfContainer(container) { - return getGeneratedNameForNode(container); - } - function getLocalNameForImportDeclaration(node) { - return getGeneratedNameForNode(node); - } - function getAliasNameSubstitution(symbol) { - var declaration = getDeclarationOfAliasSymbol(symbol); - if (declaration && declaration.kind === 208) { - var moduleName = getGeneratedNameForNode(declaration.parent.parent.parent); - var propertyName = declaration.propertyName || declaration.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - function getExportNameSubstitution(symbol, location) { + function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { if (isExternalModuleSymbol(symbol.parent)) { + if (languageVersion >= 2) { + return undefined; + } return "exports." + ts.unescapeIdentifier(symbol.name); } var node = location; var containerSymbol = getParentOfSymbol(symbol); while (node) { - if ((node.kind === 200 || node.kind === 199) && getSymbolOfNode(node) === containerSymbol) { + if ((node.kind === 202 || node.kind === 201) && getSymbolOfNode(node) === containerSymbol) { return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); } node = node.parent; } } - function getExpressionNameSubstitution(node) { - var symbol = getNodeLinks(node).resolvedSymbol; + function getExpressionNameSubstitution(node, getGeneratedNameForNode) { + var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); if (symbol) { if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent); + return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); } var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (symbol !== exportSymbol && !(exportSymbol.flags & 944)) { - return getExportNameSubstitution(exportSymbol, node.parent); + return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); } if (symbol.flags & 8388608) { - return getAliasNameSubstitution(symbol); + return getAliasNameSubstitution(symbol, getGeneratedNameForNode); } } } - function hasExportDefaultValue(node) { - var symbol = getResolvedExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbol !== unknownSymbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol); + function isValueAliasDeclaration(node) { + switch (node.kind) { + case 205: + case 207: + case 208: + case 210: + case 214: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 212: + var exportClause = node.exportClause; + return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 211: + return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 221 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 224 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } return isAliasResolvedToValue(getSymbolOfNode(node)); @@ -16942,14 +17758,17 @@ var ts; function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; } - function isReferencedAliasDeclaration(node) { - if (isAliasSymbolDeclaration(node)) { + function isReferencedAliasDeclaration(node, checkChildren) { + if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { return true; } } - return ts.forEachChild(node, isReferencedAliasDeclaration); + if (checkChildren) { + return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + } + return false; } function isImplementationOfOverload(node) { if (ts.nodeIsPresent(node.body)) { @@ -16968,15 +17787,13 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 220) { + if (node.kind === 223) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8)) { - var declaration = symbol.valueDeclaration; - var constantValue; - if (declaration.kind === 220) { - return getEnumMemberValue(declaration); + if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); } } return undefined; @@ -16992,42 +17809,48 @@ var ts; var signature = getSignatureFromDeclaration(signatureDeclaration); getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } - function isUnknownIdentifier(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "isUnknownIdentifier called with a synthesized location"); - return !resolveName(location, name, 107455, undefined, undefined) && - !ts.hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name); + function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function hasGlobalName(name) { + return ts.hasProperty(globals, name); + } + function resolvesToSomeValue(location, name) { + ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); + return !!resolveName(location, name, 107455, undefined, undefined); } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - if (n.parent.kind === 153 && - n.parent.name === n) { - return undefined; - } - if (n.parent.kind === 150 && - n.parent.propertyName === n) { - return undefined; - } - var declarationSymbol = (n.parent.kind === 193 && n.parent.name === n) || - n.parent.kind === 150 - ? getSymbolOfNode(n.parent) - : undefined; - var symbol = declarationSymbol || + var isVariableDeclarationOrBindingElement = n.parent.kind === 152 || (n.parent.kind === 195 && n.parent.name === n); + var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 217; + symbol.valueDeclaration.parent.kind !== 220; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; } return undefined; } + function instantiateSingleCallFunctionType(functionType, typeArguments) { + if (functionType === unknownType) { + return unknownType; + } + var signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } function createResolver() { return { - getGeneratedNameForNode: getGeneratedNameForNode, getExpressionNameSubstitution: getExpressionNameSubstitution, - hasExportDefaultValue: hasExportDefaultValue, + isValueAliasDeclaration: isValueAliasDeclaration, + hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, getNodeCheckFlags: getNodeCheckFlags, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, @@ -17035,10 +17858,12 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression: writeTypeOfExpression, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - isUnknownIdentifier: isUnknownIdentifier, + resolvesToSomeValue: resolvesToSomeValue, + collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId }; } @@ -17063,6 +17888,11 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); + globalClassDecoratorType = getGlobalType("ClassDecorator"); + globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); + globalMethodDecoratorType = getGlobalType("MethodDecorator"); + globalParameterDecoratorType = getGlobalType("ParameterDecorator"); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -17076,28 +17906,46 @@ var ts; } anyArrayType = createArrayType(anyType); } + function checkGrammarDecorators(node) { + if (!node.decorators) { + return false; + } + if (!ts.nodeCanBeDecorated(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + else if (languageVersion < 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (node.kind === 136 || node.kind === 137) { + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } function checkGrammarModifiers(node) { switch (node.kind) { - case 134: + case 136: + case 137: case 135: - case 133: - case 130: - case 129: case 132: case 131: - case 138: - case 196: + case 134: + case 133: + case 140: + case 198: + case 199: + case 202: + case 201: + case 177: case 197: case 200: - case 199: - case 175: - case 195: - case 198: - case 204: - case 203: - case 210: - case 209: - case 128: + case 206: + case 205: + case 212: + case 211: + case 129: break; default: return false; @@ -17110,14 +17958,14 @@ var ts; for (var _i = 0, _a = node.modifiers, _n = _a.length; _i < _n; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 109: case 108: case 107: - case 106: var text = void 0; - if (modifier.kind === 108) { + if (modifier.kind === 109) { text = "public"; } - else if (modifier.kind === 107) { + else if (modifier.kind === 108) { text = "protected"; lastProtected = modifier; } @@ -17131,50 +17979,50 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 201 || node.parent.kind === 221) { + else if (node.parent.kind === 203 || node.parent.kind === 224) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); break; - case 109: + case 110: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 201 || node.parent.kind === 221) { + else if (node.parent.kind === 203 || node.parent.kind === 224) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; lastStatic = modifier; break; - case 77: + case 78: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 114: + case 115: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 201) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 203) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -17182,7 +18030,7 @@ var ts; break; } } - if (node.kind === 133) { + if (node.kind === 135) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -17193,13 +18041,13 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 204 || node.kind === 203) && flags & 2) { + else if ((node.kind === 206 || node.kind === 205) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 197 && flags & 2) { + else if (node.kind === 199 && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } - else if (node.kind === 128 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 129 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -17211,15 +18059,14 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters) { + function checkGrammarTypeParameterList(node, typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } if (typeParameters && typeParameters.length === 0) { var start = typeParameters.pos - "<".length; - var sourceFile = ts.getSourceFileOfNode(node); - var end = ts.skipTrivia(sourceFile.text, typeParameters.end) + ">".length; - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); + var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } } function checkGrammarParameterList(parameters) { @@ -17255,7 +18102,20 @@ var ts; } } function checkGrammarFunctionLikeDeclaration(node) { - return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); + var file = ts.getSourceFileOfNode(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + } + function checkGrammarArrowFunction(node, file) { + if (node.kind === 163) { + var arrowFunction = node; + var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + if (startLine !== endLine) { + return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); + } + } + return false; } function checkGrammarIndexSignatureParameters(node) { var parameter = node.parameters[0]; @@ -17282,7 +18142,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 120 && parameter.type.kind !== 118) { + if (parameter.type.kind !== 121 && parameter.type.kind !== 119) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -17295,7 +18155,7 @@ var ts; } } function checkGrammarIndexSignature(node) { - checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); } function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { if (typeArguments && typeArguments.length === 0) { @@ -17314,7 +18174,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, _n = arguments.length; _i < _n; _i++) { var arg = arguments[_i]; - if (arg.kind === 172) { + if (arg.kind === 174) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -17338,10 +18198,10 @@ var ts; function checkGrammarClassDeclarationHeritageClauses(node) { var seenExtendsClause = false; var seenImplementsClause = false; - if (!checkGrammarModifiers(node) && node.heritageClauses) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses, _n = _a.length; _i < _n; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 78) { + if (heritageClause.token === 79) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -17354,7 +18214,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -17369,14 +18229,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses, _n = _a.length; _i < _n; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 78) { + if (heritageClause.token === 79) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -17385,11 +18245,11 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 126) { + if (node.kind !== 127) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 167 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 169 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -17415,52 +18275,52 @@ var ts; var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties, _n = _a.length; _i < _n; _i++) { var prop = _a[_i]; - var _name = prop.name; - if (prop.kind === 172 || - _name.kind === 126) { - checkGrammarComputedPropertyName(_name); + var name_11 = prop.name; + if (prop.kind === 174 || + name_11.kind === 127) { + checkGrammarComputedPropertyName(name_11); continue; } var currentKind = void 0; - if (prop.kind === 218 || prop.kind === 219) { + if (prop.kind === 221 || prop.kind === 222) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (_name.kind === 7) { - checkGrammarNumbericLiteral(_name); + if (name_11.kind === 7) { + checkGrammarNumbericLiteral(name_11); } currentKind = Property; } - else if (prop.kind === 132) { + else if (prop.kind === 134) { currentKind = Property; } - else if (prop.kind === 134) { + else if (prop.kind === 136) { currentKind = GetAccessor; } - else if (prop.kind === 135) { + else if (prop.kind === 137) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, _name.text)) { - seen[_name.text] = currentKind; + if (!ts.hasProperty(seen, name_11.text)) { + seen[name_11.text] = currentKind; } else { - var existingKind = seen[_name.text]; + var existingKind = seen[name_11.text]; if (currentKind === Property && existingKind === Property) { if (inStrictMode) { - grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); } } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[_name.text] = currentKind | existingKind; + seen[name_11.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -17469,27 +18329,27 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 194) { + if (forInOrOfStatement.initializer.kind === 196) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var _diagnostic = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; - return grammarErrorOnNode(firstDeclaration.name, _diagnostic); + return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var _diagnostic_1 = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; - return grammarErrorOnNode(firstDeclaration, _diagnostic_1); + return grammarErrorOnNode(firstDeclaration, diagnostic); } } } @@ -17509,10 +18369,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 134 && accessor.parameters.length) { + else if (kind === 136 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 135) { + else if (kind === 137) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -17537,7 +18397,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 126 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 127 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -17547,7 +18407,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 152) { + if (node.parent.kind === 154) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -17555,7 +18415,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 196) { + if (node.parent.kind === 198) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -17566,22 +18426,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 197) { + else if (node.parent.kind === 199) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 143) { + else if (node.parent.kind === 145) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 183: + case 184: + case 185: case 181: case 182: - case 183: - case 179: - case 180: return true; - case 189: + case 191: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -17593,9 +18453,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 189: + case 191: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 184 + var isMisplacedContinueLabel = node.kind === 186 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -17603,8 +18463,8 @@ var ts; return false; } break; - case 188: - if (node.kind === 185 && !node.label) { + case 190: + if (node.kind === 187 && !node.label) { return false; } break; @@ -17617,16 +18477,16 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 185 + var message = node.kind === 187 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var _message = node.kind === 185 + var message = node.kind === 187 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, _message); + return grammarErrorOnNode(node, message); } } function checkGrammarBindingElement(node) { @@ -17642,7 +18502,7 @@ var ts; return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 182 && node.parent.parent.kind !== 183) { + if (node.parent.parent.kind !== 184 && node.parent.parent.kind !== 185) { if (ts.isInAmbientContext(node)) { if (ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); @@ -17666,7 +18526,7 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 64) { + if (name.kind === 65) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -17690,15 +18550,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 178: - case 179: case 180: - case 187: case 181: case 182: - case 183: - return false; case 189: + case 183: + case 184: + case 185: + return false; + case 191: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -17714,7 +18574,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 165) { + if (expression.kind === 167) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -17733,7 +18593,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members, _n = _a.length; _i < _n; _i++) { var node = _a[_i]; - if (node.name.kind === 126) { + if (node.name.kind === 127) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -17776,7 +18636,7 @@ var ts; } } function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 64) { + if (name && name.kind === 65) { var identifier = name; if (contextNode && (contextNode.parserContextFlags & 1) && ts.isEvalOrArgumentsIdentifier(identifier)) { var nameText = ts.declarationNameToString(identifier); @@ -17795,18 +18655,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 196) { + if (node.parent.kind === 198) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 197) { + else if (node.parent.kind === 199) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 143) { + else if (node.parent.kind === 145) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -17816,12 +18676,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 197 || - node.kind === 204 || - node.kind === 203 || - node.kind === 210 || - node.kind === 209 || - (node.flags & 2)) { + if (node.kind === 199 || + node.kind === 206 || + node.kind === 205 || + node.kind === 212 || + node.kind === 211 || + (node.flags & 2) || + (node.flags & (1 | 256))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -17829,7 +18690,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements, _n = _a.length; _i < _n; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 175) { + if (ts.isDeclaration(decl) || decl.kind === 177) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -17848,10 +18709,10 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 174 || node.parent.kind === 201 || node.parent.kind === 221) { - var _links = getNodeLinks(node.parent); - if (!_links.hasReportedStatementInAmbientContext) { - return _links.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + if (node.parent.kind === 176 || node.parent.kind === 203 || node.parent.kind === 224) { + var links_1 = getNodeLinks(node.parent); + if (!links_1.hasReportedStatementInAmbientContext) { + return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } else { @@ -17881,251 +18742,16 @@ var ts; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); +/// var ts; (function (ts) { - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!ts.isDeclarationFile(sourceFile)) { - if ((ts.isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - return true; - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(ts.getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - var lineCount = ts.getLineStarts(currentSourceFile).length; - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : ts.getStartPositionOfLine(currentLine + 1, currentSourceFile); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(ts.getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 133 && ts.nodeIsPresent(member.body)) { - return member; - } - }); - } - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var getAccessor; - var setAccessor; - if (ts.hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 134) { - getAccessor = accessor; - } - else if (accessor.kind === 135) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 134 || member.kind === 135) - && (member.flags & 128) === (accessor.flags & 128)) { - var memberName = ts.getPropertyNameForPropertyNameNode(member.name); - var accessorName = ts.getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 134 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 135 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); + function getDeclarationDiagnostics(host, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); @@ -18141,7 +18767,8 @@ var ts; var reportedDeclarationError = false; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; - var aliasDeclarationEmitInfo = []; + var moduleElementDeclarationEmitInfo = []; + var asynchronousSubModuleDeclarationEmitInfo; var referencePathsOutput = ""; if (root) { if (!compilerOptions.noResolve) { @@ -18149,25 +18776,38 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); if (referencedFile && ((referencedFile.flags & 2048) || - shouldEmitToOwnFile(referencedFile, compilerOptions) || + ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); - if (!isExternalModuleOrDeclarationFile(referencedFile)) { + if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { addedGlobalFileReference = true; } } }); } emitSourceFile(root); + if (moduleElementDeclarationEmitInfo.length) { + var oldWriter = writer; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.isVisible) { + ts.Debug.assert(aliasEmitInfo.node.kind === 206); + createAndSetNewTextWriterWithSymbolWriter(); + ts.Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } } else { var emittedReferencedFiles = []; ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { + if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { if (!compilerOptions.noResolve) { ts.forEach(sourceFile.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); - if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && + if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) { writeReferencePath(referencedFile); emittedReferencedFiles.push(referencedFile); @@ -18180,7 +18820,7 @@ var ts; } return { reportedDeclarationError: reportedDeclarationError, - aliasDeclarationEmitInfo: aliasDeclarationEmitInfo, + moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), referencePathsOutput: referencePathsOutput }; @@ -18199,17 +18839,17 @@ var ts; } } function createAndSetNewTextWriterWithSymbolWriter() { - var _writer = createTextWriter(newLine); - _writer.trackSymbol = trackSymbol; - _writer.writeKeyword = _writer.write; - _writer.writeOperator = _writer.write; - _writer.writePunctuation = _writer.write; - _writer.writeSpace = _writer.write; - _writer.writeStringLiteral = _writer.writeLiteral; - _writer.writeParameter = _writer.write; - _writer.writeSymbol = _writer.write; - setWriter(_writer); - return _writer; + var writer = ts.createTextWriter(newLine); + writer.trackSymbol = trackSymbol; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + setWriter(writer); + return writer; } function setWriter(newWriter) { writer = newWriter; @@ -18219,17 +18859,43 @@ var ts; increaseIndent = newWriter.increaseIndent; decreaseIndent = newWriter.decreaseIndent; } - function writeAsychronousImportEqualsDeclarations(importEqualsDeclarations) { + function writeAsynchronousModuleElements(nodes) { var oldWriter = writer; - ts.forEach(importEqualsDeclarations, function (aliasToWrite) { - var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); - if (aliasEmitInfo) { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); + ts.forEach(nodes, function (declaration) { + var nodeToCheck; + if (declaration.kind === 195) { + nodeToCheck = declaration.parent.parent; + } + else if (declaration.kind === 209 || declaration.kind === 210 || declaration.kind === 207) { + ts.Debug.fail("We should be getting ImportDeclaration instead to write"); + } + else { + nodeToCheck = declaration; + } + var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + } + if (moduleElementEmitInfo) { + if (moduleElementEmitInfo.node.kind === 206) { + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + if (nodeToCheck.kind === 202) { + ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === 202) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); } - writeImportEqualsDeclaration(aliasToWrite); - aliasEmitInfo.asynchronousOutput = writer.getText(); } }); setWriter(oldWriter); @@ -18237,7 +18903,7 @@ var ts; function handleSymbolAccessibilityError(symbolAccesibilityResult) { if (symbolAccesibilityResult.accessibility === 0) { if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportEqualsDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); } } else { @@ -18282,25 +18948,27 @@ var ts; emit(node); } } - function emitSeparatedList(nodes, separator, eachNodeEmitFn) { + function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var node = nodes[_i]; - if (currentWriterPos !== writer.getTextPos()) { - write(separator); + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); } } - function emitCommaList(nodes, eachNodeEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn); + function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); } function writeJsDocComments(declaration) { if (declaration) { var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -18309,44 +18977,44 @@ var ts; } function emitType(type) { switch (type.kind) { - case 111: - case 120: - case 118: case 112: case 121: - case 98: + case 119: + case 113: + case 122: + case 99: case 8: return writeTextOfNode(currentSourceFile, type); - case 139: - return emitTypeReference(type); - case 142: - return emitTypeQuery(type); - case 144: - return emitArrayType(type); - case 145: - return emitTupleType(type); - case 146: - return emitUnionType(type); - case 147: - return emitParenType(type); - case 140: case 141: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 144: + return emitTypeQuery(type); + case 146: + return emitArrayType(type); + case 147: + return emitTupleType(type); + case 148: + return emitUnionType(type); + case 149: + return emitParenType(type); + case 142: case 143: + return emitSignatureDeclarationWithJsDocComments(type); + case 145: return emitTypeLiteral(type); - case 64: + case 65: return emitEntityName(type); - case 125: + case 126: return emitEntityName(type); default: ts.Debug.fail("Unknown type annotation: " + type.kind); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 203 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 205 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { - if (entityName.kind === 64) { + if (entityName.kind === 65) { writeTextOfNode(currentSourceFile, entityName); } else { @@ -18404,16 +19072,100 @@ var ts; } function emitExportAssignment(node) { write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); + if (node.expression.kind === 65) { + writeTextOfNode(currentSourceFile, node.expression); + } + else { + write(": "); + if (node.type) { + emitType(node.type); + } + else { + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + } + } write(";"); writeLine(); + if (node.expression.kind === 65) { + var nodes = resolver.collectLinkedAliases(node.expression); + writeAsynchronousModuleElements(nodes); + } + function getDefaultExportAccessibilityDiagnostic(diagnostic) { + return { + diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + function isModuleElementVisible(node) { + return resolver.isDeclarationVisible(node); + } + function emitModuleElement(node, isModuleElementVisible) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + else if (node.kind === 205 || + (node.parent.kind === 224 && ts.isExternalModule(currentSourceFile))) { + var isVisible; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 224) { + asynchronousSubModuleDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + else { + if (node.kind === 206) { + var importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + } + } + function writeModuleElement(node) { + switch (node.kind) { + case 197: + return writeFunctionDeclaration(node); + case 177: + return writeVariableStatement(node); + case 199: + return writeInterfaceDeclaration(node); + case 198: + return writeClassDeclaration(node); + case 200: + return writeTypeAliasDeclaration(node); + case 201: + return writeEnumDeclaration(node); + case 202: + return writeModuleDeclaration(node); + case 205: + return writeImportEqualsDeclaration(node); + case 206: + return writeImportDeclaration(node); + default: + ts.Debug.fail("Unknown symbol kind"); + } } function emitModuleElementDeclarationFlags(node) { if (node.parent === currentSourceFile) { if (node.flags & 1) { write("export "); } - if (node.kind !== 197) { + if (node.flags & 256) { + write("default "); + } + else if (node.kind !== 199) { write("declare "); } } @@ -18429,18 +19181,6 @@ var ts; write("static "); } } - function emitImportEqualsDeclaration(node) { - var nodeEmitInfo = { - declaration: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - hasWritten: resolver.isDeclarationVisible(node) - }; - aliasDeclarationEmitInfo.push(nodeEmitInfo); - if (nodeEmitInfo.hasWritten) { - writeImportEqualsDeclaration(node); - } - } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); if (node.flags & 1) { @@ -18467,40 +19207,110 @@ var ts; }; } } - function emitModuleDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("module "); - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 201) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); + function isVisibleNamedBinding(namedBindings) { + if (namedBindings) { + if (namedBindings.kind === 208) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; } } - function emitTypeAliasDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); + function writeImportDeclaration(node) { + if (!node.importClause && !(node.flags & 1)) { + return; } + emitJsDocComments(node); + if (node.flags & 1) { + write("export "); + } + write("import "); + if (node.importClause) { + var currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + write(", "); + } + if (node.importClause.namedBindings.kind === 208) { + write("* as "); + writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); + } + else { + write("{ "); + emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + function emitImportOrExportSpecifier(node) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + function emitExportSpecifier(node) { + emitImportOrExportSpecifier(node); + var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + writeAsynchronousModuleElements(nodes); + } + function emitExportDeclaration(node) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + function writeModuleDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("module "); + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== 203) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeTypeAliasDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -18509,23 +19319,21 @@ var ts; }; } } - function emitEnumDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); + function writeEnumDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isConst(node)) { + write("const "); } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); } function emitEnumMemberDeclaration(node) { emitJsDocComments(node); @@ -18539,7 +19347,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 132 && (node.parent.flags & 32); + return node.parent.kind === 134 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -18549,15 +19357,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 140 || - node.parent.kind === 141 || - (node.parent.parent && node.parent.parent.kind === 143)) { - ts.Debug.assert(node.parent.kind === 132 || - node.parent.kind === 131 || - node.parent.kind === 140 || - node.parent.kind === 141 || - node.parent.kind === 136 || - node.parent.kind === 137); + if (node.parent.kind === 142 || + node.parent.kind === 143 || + (node.parent.parent && node.parent.parent.kind === 145)) { + ts.Debug.assert(node.parent.kind === 134 || + node.parent.kind === 133 || + node.parent.kind === 142 || + node.parent.kind === 143 || + node.parent.kind === 138 || + node.parent.kind === 139); emitType(node.constraint); } else { @@ -18567,31 +19375,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 196: + case 198: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 197: + case 199: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 137: + case 139: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: + case 138: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 132: - case 131: + case 134: + case 133: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 196) { + else if (node.parent.parent.kind === 198) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 195: + case 197: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -18619,7 +19427,7 @@ var ts; emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 196) { + if (node.parent.parent.kind === 198) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -18635,7 +19443,7 @@ var ts; } } } - function emitClassDeclaration(node) { + function writeClassDeclaration(node) { function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { @@ -18645,49 +19453,45 @@ var ts; }); } } - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassBaseTypeNode(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); - } - emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("class "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); } + emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(ts.getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; } - function emitInterfaceDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } + function writeInterfaceDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; } function emitPropertyDeclaration(node) { if (ts.hasDynamicName(node)) { @@ -18700,54 +19504,83 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 193 || resolver.isDeclarationVisible(node)) { - writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 130 || node.kind === 129) && ts.hasQuestionToken(node)) { - write("?"); + if (node.kind !== 195 || resolver.isDeclarationVisible(node)) { + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); } - if ((node.kind === 130 || node.kind === 129) && node.parent.kind === 143) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + else { + writeTextOfNode(currentSourceFile, node.name); + if ((node.kind === 132 || node.kind === 131) && ts.hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === 132 || node.kind === 131) && node.parent.kind === 145) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & 32)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 193) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + if (node.kind === 195) { + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 130 || node.kind === 129) { + else if (node.kind === 132 || node.kind === 131) { if (node.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 196) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + else if (node.parent.kind === 198) { + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, typeName: node.name } : undefined; } + function emitBindingPattern(bindingPattern) { + emitCommaList(bindingPattern.elements, emitBindingElement); + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + } + } + } } function emitTypeOfVariableDeclarationFromTypeLiteral(node) { if (node.type) { @@ -18755,30 +19588,30 @@ var ts; emitType(node.type); } } - function emitVariableStatement(node) { - var hasDeclarationWithEmit = ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - if (hasDeclarationWithEmit) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node.declarationList)) { - write("let "); - } - else if (ts.isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration); - write(";"); - writeLine(); + function isVariableStatementVisible(node) { + return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + } + function writeVariableStatement(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isLet(node.declarationList)) { + write("let "); } + else if (ts.isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); } function emitAccessorDeclaration(node) { if (ts.hasDynamicName(node)) { return; } - var accessors = getAllAccessorDeclarations(node.parent.members, node); + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); var accessorWithTypeAnnotation; if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); @@ -18789,7 +19622,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 134 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 136 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -18802,7 +19635,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 134 + return accessor.kind === 136 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -18811,7 +19644,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 135) { + if (accessorWithTypeAnnotation.kind === 137) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -18851,24 +19684,23 @@ var ts; } } } - function emitFunctionDeclaration(node) { + function writeFunctionDeclaration(node) { if (ts.hasDynamicName(node)) { return; } - if ((node.kind !== 195 || resolver.isDeclarationVisible(node)) && - !resolver.isImplementationOfOverload(node)) { + if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 195) { + if (node.kind === 197) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 132) { + else if (node.kind === 134) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 195) { + if (node.kind === 197) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 133) { + else if (node.kind === 135) { write("constructor"); } else { @@ -18885,11 +19717,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 137 || node.kind === 141) { + if (node.kind === 139 || node.kind === 143) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 138) { + if (node.kind === 140) { write("["); } else { @@ -18898,20 +19730,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 138) { + if (node.kind === 140) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 140 || node.kind === 141; - if (isFunctionTypeOrConstructorType || node.parent.kind === 143) { + var isFunctionTypeOrConstructorType = node.kind === 142 || node.kind === 143; + if (isFunctionTypeOrConstructorType || node.parent.kind === 145) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 133 && !(node.flags & 32)) { + else if (node.kind !== 135 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -18922,23 +19754,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 137: + case 139: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 136: + case 138: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 138: + case 140: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 132: - case 131: + case 134: + case 133: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -18946,7 +19778,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -18959,7 +19791,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 195: + case 197: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -18991,9 +19823,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 140 || - node.parent.kind === 141 || - node.parent.parent.kind === 143) { + if (node.parent.kind === 142 || + node.parent.kind === 143 || + node.parent.parent.kind === 145) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -19002,25 +19834,25 @@ var ts; function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 133: + case 135: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; - case 137: + case 139: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: + case 138: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 132: - case 131: + case 134: + case 133: if (node.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -19028,7 +19860,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 196) { + else if (node.parent.parent.kind === 198) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -19041,7 +19873,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 195: + case 197: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -19060,60 +19892,90 @@ var ts; } function emitNode(node) { switch (node.kind) { + case 197: + case 202: + case 205: + case 199: + case 198: + case 200: + case 201: + return emitModuleElement(node, isModuleElementVisible(node)); + case 177: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 206: + return emitModuleElement(node, !node.importClause); + case 212: + return emitExportDeclaration(node); + case 135: + case 134: case 133: - case 195: + return writeFunctionDeclaration(node); + case 139: + case 138: + case 140: + return emitSignatureDeclarationWithJsDocComments(node); + case 136: + case 137: + return emitAccessorDeclaration(node); case 132: case 131: - return emitFunctionDeclaration(node); - case 137: - case 136: - case 138: - return emitSignatureDeclarationWithJsDocComments(node); - case 134: - case 135: - return emitAccessorDeclaration(node); - case 175: - return emitVariableStatement(node); - case 130: - case 129: return emitPropertyDeclaration(node); - case 197: - return emitInterfaceDeclaration(node); - case 196: - return emitClassDeclaration(node); - case 198: - return emitTypeAliasDeclaration(node); - case 220: + case 223: return emitEnumMemberDeclaration(node); - case 199: - return emitEnumDeclaration(node); - case 200: - return emitModuleDeclaration(node); - case 203: - return emitImportEqualsDeclaration(node); - case 209: + case 211: return emitExportAssignment(node); - case 221: + case 224: return emitSourceFile(node); } } function writeReferencePath(referencedFile) { var declFileName = referencedFile.flags & 2048 ? referencedFile.fileName - : shouldEmitToOwnFile(referencedFile, compilerOptions) - ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") + : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) + ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } } - function getDeclarationDiagnostics(host, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; + function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { + var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + if (!emitDeclarationResult.reportedDeclarationError) { + var declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { + var appliedSyncOutputPos = 0; + var declarationOutput = ""; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return declarationOutput; + } } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + ts.writeDeclarationFile = writeDeclarationFile; +})(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + TempFlags[TempFlags["_n"] = 536870912] = "_n"; + })(TempFlags || (TempFlags = {})); function emitFiles(resolver, host, targetSourceFile) { var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; @@ -19122,8 +19984,8 @@ var ts; var newLine = host.getNewLine(); if (targetSourceFile === undefined) { ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, ".js"); + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -19132,8 +19994,8 @@ var ts; } } else { - if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -19146,8 +20008,26 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } function emitJavaScript(jsFilePath, root) { - var writer = createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var write = writer.write; var writeTextOfNode = writer.writeTextOfNode; var writeLine = writer.writeLine; @@ -19155,26 +20035,23 @@ var ts; var decreaseIndent = writer.decreaseIndent; var preserveNewLines = compilerOptions.preserveNewLines || false; var currentSourceFile; - var lastFrame; - var currentScopeNames; - var generatedBlockScopeNames; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var blockScopedVariableToGeneratedName; + var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; - var tempCount = 0; + var decorateEmitted = false; + var tempFlags = 0; var tempVariables; var tempParameters; var externalImports; var exportSpecifiers; - var exportDefault; + var exportEquals; + var hasExportStars; var writeEmittedFiles = writeJavaScriptFile; - var emitLeadingComments = compilerOptions.removeComments ? function (node) { } : emitLeadingDeclarationComments; - var emitTrailingComments = compilerOptions.removeComments ? function (node) { } : emitTrailingDeclarationComments; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfLocalPosition; var detachedCommentsInfo; - var emitDetachedComments = compilerOptions.removeComments ? function (node) { } : emitDetachedCommentsAtPosition; - var writeComment = writeCommentRange; - var emitNodeWithoutSourceMap = compilerOptions.removeComments ? emitNodeWithoutSourceMapWithoutComments : emitNodeWithoutSourceMapWithComments; + var writeComment = ts.writeCommentRange; var emit = emitNodeWithoutSourceMap; - var emitWithoutComments = emitNodeWithoutSourceMapWithoutComments; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; @@ -19201,55 +20078,108 @@ var ts; currentSourceFile = sourceFile; emit(sourceFile); } - function enterNameScope() { - var names = currentScopeNames; - currentScopeNames = undefined; - if (names) { - lastFrame = { names: names, previous: lastFrame }; - return true; - } - return false; + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); } - function exitNameScope(popFrame) { - if (popFrame) { - currentScopeNames = lastFrame.names; - lastFrame = lastFrame.previous; - } - else { - currentScopeNames = undefined; - } - } - function generateUniqueNameForLocation(location, baseName) { - var _name; - if (!isExistingName(location, baseName)) { - _name = baseName; - } - else { - _name = ts.generateUniqueName(baseName, function (n) { return isExistingName(location, n); }); - } - return recordNameInCurrentScope(_name); - } - function recordNameInCurrentScope(name) { - if (!currentScopeNames) { - currentScopeNames = {}; - } - return currentScopeNames[name] = name; - } - function isExistingName(location, name) { - if (!resolver.isUnknownIdentifier(location, name)) { - return true; - } - if (currentScopeNames && ts.hasProperty(currentScopeNames, name)) { - return true; - } - var frame = lastFrame; - while (frame) { - if (ts.hasProperty(frame.names, name)) { - return true; + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { + tempFlags |= flags; + return name; } - frame = frame.previous; } - return false; + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_12 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_12)) { + return name_12; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function assignGeneratedName(node, name) { + nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); + } + function generateNameForFunctionOrClassDeclaration(node) { + if (!node.name) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForModuleOrEnum(node) { + if (node.name.kind === 65) { + var name_13 = node.name.text; + assignGeneratedName(node, isUniqueLocalName(name_13, node) ? name_13 : makeUniqueName(name_13)); + } + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 8 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + assignGeneratedName(node, makeUniqueName(baseName)); + } + function generateNameForImportDeclaration(node) { + if (node.importClause) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportDeclaration(node) { + if (node.moduleSpecifier) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportAssignment(node) { + if (node.expression && node.expression.kind !== 65) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForNode(node) { + switch (node.kind) { + case 197: + case 198: + generateNameForFunctionOrClassDeclaration(node); + break; + case 202: + generateNameForModuleOrEnum(node); + generateNameForNode(node.body); + break; + case 201: + generateNameForModuleOrEnum(node); + break; + case 206: + generateNameForImportDeclaration(node); + break; + case 212: + generateNameForExportDeclaration(node); + break; + case 211: + generateNameForExportAssignment(node); + break; + } + } + function getGeneratedNameForNode(node) { + var nodeId = ts.getNodeId(node); + if (!nodeToGeneratedName[nodeId]) { + generateNameForNode(node); + } + return nodeToGeneratedName[nodeId]; } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -19375,8 +20305,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var _name = node.name; - if (!_name || _name.kind !== 126) { + var name_14 = node.name; + if (!name_14 || name_14.kind !== 127) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -19393,19 +20323,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 195 || - node.kind === 160 || - node.kind === 132 || - node.kind === 131 || + else if (node.kind === 197 || + node.kind === 162 || node.kind === 134 || - node.kind === 135 || - node.kind === 200 || - node.kind === 196 || - node.kind === 199) { + node.kind === 133 || + node.kind === 136 || + node.kind === 137 || + node.kind === 202 || + node.kind === 198 || + node.kind === 201) { if (node.name) { - var _name = node.name; - scopeName = _name.kind === 126 - ? ts.getTextOfNode(_name) + var name_15 = node.name; + scopeName = name_15.kind === 127 + ? ts.getTextOfNode(name_15) : node.name.text; } recordScopeNameStart(scopeName); @@ -19420,7 +20350,7 @@ var ts; ; function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { recordSourceMapSpan(comment.pos); - writeCommentRange(currentSourceFile, writer, comment, newLine); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { @@ -19448,7 +20378,7 @@ var ts; } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { encodeLastRecordedSourceMapSpan(); - writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); sourceMapDataList.push(sourceMapData); writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); } @@ -19471,7 +20401,7 @@ var ts; if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); if (root) { - sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, host, sourceMapDir)); + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -19484,32 +20414,24 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node) { + function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); + return emitNodeWithoutSourceMap(node, false); } - if (node.kind != 221) { + if (node.kind != 224) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, false); } } } - function emitNodeWithSourceMapWithoutComments(node) { - if (node) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMapWithoutComments(node); - recordEmitNodeEndSpan(node); - } - } writeEmittedFiles = writeJavaScriptAndSourceMapFile; emit = emitNodeWithSourceMap; - emitWithoutComments = emitNodeWithSourceMapWithoutComments; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -19518,24 +20440,11 @@ var ts; writeComment = writeCommentRangeWithMap; } function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } - function createTempVariable(location, preferredName) { - for (var name = preferredName; !name || isExistingName(location, name); tempCount++) { - var char = 97 + tempCount; - if (char === 105 || char === 110) { - continue; - } - if (tempCount < 26) { - name = "_" + String.fromCharCode(char); - } - else { - name = "_" + (tempCount - 26); - } - } - recordNameInCurrentScope(name); - var result = ts.createSynthesizedNode(64); - result.text = name; + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(65); + result.text = makeTempVariableName(flags); return result; } function recordTempDeclaration(name) { @@ -19544,8 +20453,8 @@ var ts; } tempVariables.push(name); } - function createAndRecordTempVariable(location, preferredName) { - var temp = createTempVariable(location, preferredName); + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); recordTempDeclaration(temp); return temp; } @@ -19737,7 +20646,7 @@ var ts; write("]"); } function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(node); + var tempVariable = createAndRecordTempVariable(0); write("("); emit(tempVariable); write(" = "); @@ -19750,10 +20659,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 169) { + if (node.template.kind === 171) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 167 + var needsParens = templateSpan.expression.kind === 169 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -19777,7 +20686,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 159 + var needsParens = templateSpan.expression.kind !== 161 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -19792,16 +20701,29 @@ var ts; write(")"); } function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar ts.Debug.assert(node.templateSpans.length !== 0); return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 155: - case 156: - return parent.expression === template; case 157: + case 158: + return parent.expression === template; case 159: + case 161: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -19809,7 +20731,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 167: + case 169: switch (expression.operatorToken.kind) { case 35: case 36: @@ -19821,7 +20743,7 @@ var ts; default: return -1; } - case 168: + case 170: return -1; default: return 1; @@ -19833,11 +20755,27 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 150); + ts.Debug.assert(node.kind !== 152); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 126) { + else if (node.kind === 127) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[node.id]; + if (generatedName) { + write(generatedName); + return; + } + var generatedVariable = createTempVariable(0); + generatedName = generatedVariable.text; + recordTempDeclaration(generatedVariable); + computedPropertyNamesToGeneratedNames[node.id] = generatedName; + write(generatedName); + write(" = "); + } emit(node.expression); } else { @@ -19852,38 +20790,43 @@ var ts; } } function isNotExpressionIdentifier(node) { - var _parent = node.parent; - switch (_parent.kind) { - case 128: - case 193: - case 150: - case 130: + var parent = node.parent; + switch (parent.kind) { case 129: - case 218: - case 219: - case 220: + case 195: + case 152: case 132: case 131: - case 195: + case 221: + case 222: + case 223: case 134: - case 135: - case 160: - case 196: + case 133: case 197: + case 136: + case 137: + case 162: + case 198: case 199: - case 200: - case 203: - return _parent.name === node; - case 185: - case 184: - case 209: + case 201: + case 202: + case 205: + case 207: + case 208: + return parent.name === node; + case 210: + case 214: + return parent.name === node || parent.propertyName === node; + case 187: + case 186: + case 211: return false; - case 189: + case 191: return node.parent.label === node; } } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node); + var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); if (substitution) { write(substitution); } @@ -19891,15 +20834,21 @@ var ts; writeTextOfNode(currentSourceFile, node); } } - function getBlockScopedVariableId(node) { - return !ts.nodeIsSynthesized(node) && resolver.getBlockScopedVariableId(node); + function getGeneratedNameForIdentifier(node) { + if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { + return undefined; + } + var variableId = resolver.getBlockScopedVariableId(node); + if (variableId === undefined) { + return undefined; + } + return blockScopedVariableToGeneratedName[variableId]; } - function emitIdentifier(node) { - var variableId = getBlockScopedVariableId(node); - if (variableId !== undefined && generatedBlockScopeNames) { - var text = generatedBlockScopeNames[variableId]; - if (text) { - write(text); + function emitIdentifier(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers) { + var generatedName = getGeneratedNameForIdentifier(node); + if (generatedName) { + write(generatedName); return; } } @@ -19922,15 +20871,17 @@ var ts; } } function emitSuper(node) { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 16) { - write("_super.prototype"); - } - else if (flags & 32) { - write("_super"); + if (languageVersion >= 2) { + write("super"); } else { - write("super"); + var flags = resolver.getNodeCheckFlags(node); + if (flags & 16) { + write("_super.prototype"); + } + else { + write("_super"); + } } } function emitObjectBindingPattern(node) { @@ -19947,7 +20898,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName); + emit(node.propertyName, false); write(": "); } if (node.dotDotDotToken) { @@ -19967,12 +20918,12 @@ var ts; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 64: - case 151: + case 65: case 153: - case 154: case 155: - case 159: + case 156: + case 157: + case 161: return false; } return true; @@ -19980,8 +20931,8 @@ var ts; function emitListWithSpread(elements, multiLine, trailingComma) { var pos = 0; var group = 0; - var _length = elements.length; - while (pos < _length) { + var length = elements.length; + while (pos < length) { if (group === 1) { write(".concat("); } @@ -19989,21 +20940,21 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 171) { + if (e.kind === 173) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { var i = pos; - while (i < _length && elements[i].kind !== 171) { + while (i < length && elements[i].kind !== 173) { i++; } write("["); if (multiLine) { increaseIndent(); } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === _length); + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); if (multiLine) { decreaseIndent(); } @@ -20017,7 +20968,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 171; + return node.kind === 173; } function emitArrayLiteral(node) { var elements = node.elements; @@ -20038,11 +20989,11 @@ var ts; return emit(parenthesizedObjectLiteral); } function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral, firstComputedPropertyIndex) { - var tempVar = createAndRecordTempVariable(originalObjectLiteral); - var initialObjectLiteral = ts.createSynthesizedNode(152); + var tempVar = createAndRecordTempVariable(0); + var initialObjectLiteral = ts.createSynthesizedNode(154); initialObjectLiteral.properties = originalObjectLiteral.properties.slice(0, firstComputedPropertyIndex); initialObjectLiteral.flags |= 512; - var propertyPatches = createBinaryExpression(tempVar, 52, initialObjectLiteral); + var propertyPatches = createBinaryExpression(tempVar, 53, initialObjectLiteral); ts.forEach(originalObjectLiteral.properties, function (property) { var patchedProperty = tryCreatePatchingPropertyAssignment(originalObjectLiteral, tempVar, property); if (patchedProperty) { @@ -20060,33 +21011,33 @@ var ts; function tryCreatePatchingPropertyAssignment(objectLiteral, tempVar, property) { var leftHandSide = createMemberAccessForPropertyName(tempVar, property.name); var maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property); - return maybeRightHandSide && createBinaryExpression(leftHandSide, 52, maybeRightHandSide, true); + return maybeRightHandSide && createBinaryExpression(leftHandSide, 53, maybeRightHandSide, true); } function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property) { switch (property.kind) { - case 218: + case 221: return property.initializer; - case 219: - return createIdentifier(resolver.getExpressionNameSubstitution(property.name)); - case 132: - return createFunctionExpression(property.parameters, property.body); + case 222: + return createIdentifier(resolver.getExpressionNameSubstitution(property.name, getGeneratedNameForNode)); case 134: - case 135: - var _a = getAllAccessorDeclarations(objectLiteral.properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + return createFunctionExpression(property.parameters, property.body); + case 136: + case 137: + var _a = ts.getAllAccessorDeclarations(objectLiteral.properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (firstAccessor !== property) { return undefined; } - var propertyDescriptor = ts.createSynthesizedNode(152); + var propertyDescriptor = ts.createSynthesizedNode(154); var descriptorProperties = []; if (getAccessor) { - var _getProperty = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body)); - descriptorProperties.push(_getProperty); + var getProperty_1 = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body)); + descriptorProperties.push(getProperty_1); } if (setAccessor) { var setProperty = createPropertyAssignment(createIdentifier("set"), createFunctionExpression(setAccessor.parameters, setAccessor.body)); descriptorProperties.push(setProperty); } - var trueExpr = ts.createSynthesizedNode(94); + var trueExpr = ts.createSynthesizedNode(95); var enumerableTrue = createPropertyAssignment(createIdentifier("enumerable"), trueExpr); descriptorProperties.push(enumerableTrue); var configurableTrue = createPropertyAssignment(createIdentifier("configurable"), trueExpr); @@ -20099,14 +21050,14 @@ var ts; } } function createParenthesizedExpression(expression) { - var result = ts.createSynthesizedNode(159); + var result = ts.createSynthesizedNode(161); result.expression = expression; return result; } function createNodeArray() { var elements = []; - for (var _i = 0; _i < arguments.length; _i++) { - elements[_i - 0] = arguments[_i]; + for (var _a = 0; _a < arguments.length; _a++) { + elements[_a - 0] = arguments[_a]; } var result = elements; result.pos = -1; @@ -20114,25 +21065,25 @@ var ts; return result; } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(167, startsOnNewLine); + var result = ts.createSynthesizedNode(169, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createExpressionStatement(expression) { - var result = ts.createSynthesizedNode(177); + var result = ts.createSynthesizedNode(179); result.expression = expression; return result; } function createMemberAccessForPropertyName(expression, memberName) { - if (memberName.kind === 64) { + if (memberName.kind === 65) { return createPropertyAccessExpression(expression, memberName); } else if (memberName.kind === 8 || memberName.kind === 7) { return createElementAccessExpression(expression, memberName); } - else if (memberName.kind === 126) { + else if (memberName.kind === 127) { return createElementAccessExpression(expression, memberName.expression); } else { @@ -20140,37 +21091,37 @@ var ts; } } function createPropertyAssignment(name, initializer) { - var result = ts.createSynthesizedNode(218); + var result = ts.createSynthesizedNode(221); result.name = name; result.initializer = initializer; return result; } function createFunctionExpression(parameters, body) { - var result = ts.createSynthesizedNode(160); + var result = ts.createSynthesizedNode(162); result.parameters = parameters; result.body = body; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(153); + var result = ts.createSynthesizedNode(155); result.expression = expression; result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(154); + var result = ts.createSynthesizedNode(156); result.expression = expression; result.argumentExpression = argumentExpression; return result; } function createIdentifier(name, startsOnNewLine) { - var result = ts.createSynthesizedNode(64, startsOnNewLine); + var result = ts.createSynthesizedNode(65, startsOnNewLine); result.text = name; return result; } function createCallExpression(invokedExpression, arguments) { - var result = ts.createSynthesizedNode(155); + var result = ts.createSynthesizedNode(157); result.expression = invokedExpression; result.arguments = arguments; return result; @@ -20181,7 +21132,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 126) { + if (properties[i].name.kind === 127) { numInitialNonComputedProperties = i; break; } @@ -20200,24 +21151,34 @@ var ts; } function emitComputedPropertyName(node) { write("["); - emit(node.expression); + emitExpressionForPropertyName(node); write("]"); } function emitMethod(node) { - emit(node.name); + emit(node.name, false); if (languageVersion < 2) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name); + emit(node.name, false); write(": "); emit(node.initializer); } function emitShorthandPropertyAssignment(node) { - emit(node.name); - if (languageVersion < 2 || resolver.getExpressionNameSubstitution(node.name)) { + emit(node.name, false); + if (languageVersion < 2) { + write(": "); + var generatedName = getGeneratedNameForIdentifier(node.name); + if (generatedName) { + write(generatedName); + } + else { + emitExpressionIdentifier(node.name); + } + } + else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { write(": "); emitExpressionIdentifier(node.name); } @@ -20227,7 +21188,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 153 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 155 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -20257,7 +21218,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); + emit(node.name, false); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -20275,20 +21236,20 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 171; }); + return ts.forEach(elements, function (e) { return e.kind === 173; }); } function skipParentheses(node) { - while (node.kind === 159 || node.kind === 158) { + while (node.kind === 161 || node.kind === 160) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 64 || node.kind === 92 || node.kind === 90) { + if (node.kind === 65 || node.kind === 93 || node.kind === 91) { emit(node); return node; } - var temp = createAndRecordTempVariable(node); + var temp = createAndRecordTempVariable(0); write("("); emit(temp); write(" = "); @@ -20299,18 +21260,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 153) { + if (expr.kind === 155) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 154) { + else if (expr.kind === 156) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 90) { + else if (expr.kind === 91) { target = expr; write("_super"); } @@ -20319,7 +21280,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 90) { + if (target.kind === 91) { emitThis(target); } else { @@ -20339,15 +21300,15 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 90) { - write("_super"); + if (node.expression.kind === 91) { + emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 153 && node.expression.expression.kind === 90; + superCall = node.expression.kind === 155 && node.expression.expression.kind === 91; } - if (superCall) { + if (superCall && languageVersion < 2) { write(".call("); emitThis(node.expression); if (node.arguments.length) { @@ -20372,7 +21333,7 @@ var ts; } } function emitTaggedTemplateExpression(node) { - if (compilerOptions.target >= 2) { + if (languageVersion >= 2) { emit(node.tag); write(" "); emit(node.template); @@ -20382,20 +21343,20 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 161) { - if (node.expression.kind === 158) { + if (!node.parent || node.parent.kind !== 163) { + if (node.expression.kind === 160) { var operand = node.expression.expression; - while (operand.kind == 158) { + while (operand.kind == 160) { operand = operand.expression; } - if (operand.kind !== 165 && - operand.kind !== 164 && - operand.kind !== 163 && - operand.kind !== 162 && + if (operand.kind !== 167 && operand.kind !== 166 && - operand.kind !== 156 && - !(operand.kind === 155 && node.parent.kind === 156) && - !(operand.kind === 160 && node.parent.kind === 155)) { + operand.kind !== 165 && + operand.kind !== 164 && + operand.kind !== 168 && + operand.kind !== 158 && + !(operand.kind === 157 && node.parent.kind === 158) && + !(operand.kind === 162 && node.parent.kind === 157)) { emit(operand); return; } @@ -20406,23 +21367,23 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(73)); + write(ts.tokenToString(74)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(96)); + write(ts.tokenToString(97)); write(" "); emit(node.expression); } function emitPrefixUnaryExpression(node) { write(ts.tokenToString(node.operator)); - if (node.operand.kind === 165) { + if (node.operand.kind === 167) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -20438,9 +21399,9 @@ var ts; write(ts.tokenToString(node.operator)); } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 52 && - (node.left.kind === 152 || node.left.kind === 151)) { - emitDestructuring(node, node.parent.kind === 177); + if (languageVersion < 2 && node.operatorToken.kind === 53 && + (node.left.kind === 154 || node.left.kind === 153)) { + emitDestructuring(node, node.parent.kind === 179); } else { emit(node.left); @@ -20476,7 +21437,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 174) { + if (node && node.kind === 176) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -20491,12 +21452,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 201) { - ts.Debug.assert(node.parent.kind === 200); + if (node.kind === 203) { + ts.Debug.assert(node.parent.kind === 202); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 201) { + if (node.kind === 203) { emitTempDeclarations(true); } decreaseIndent(); @@ -20505,7 +21466,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 174) { + if (node.kind === 176) { write(" "); emit(node); } @@ -20517,11 +21478,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 161); + emitParenthesizedIf(node.expression, node.expression.kind === 163); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); endPos = emitToken(16, endPos); emit(node.expression); @@ -20529,8 +21490,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(75, node.thenStatement.end); - if (node.elseStatement.kind === 178) { + emitToken(76, node.thenStatement.end); + if (node.elseStatement.kind === 180) { write(" "); emit(node.elseStatement); } @@ -20542,7 +21503,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 174) { + if (node.statement.kind === 176) { write(" "); } else { @@ -20559,13 +21520,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitStartOfVariableDeclarationList(decl, startPos) { - var tokenKind = 97; + var tokenKind = 98; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 104; + tokenKind = 105; } else if (ts.isConst(decl)) { - tokenKind = 69; + tokenKind = 70; } } if (startPos !== undefined) { @@ -20573,20 +21534,20 @@ var ts; } else { switch (tokenKind) { - case 97: + case 98: return write("var "); - case 104: + case 105: return write("let "); - case 69: + case 70: return write("const "); } } } function emitForStatement(node) { - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 194) { + if (node.initializer && node.initializer.kind === 196) { var variableDeclarationList = node.initializer; var declarations = variableDeclarationList.declarations; emitStartOfVariableDeclarationList(declarations[0], endPos); @@ -20604,13 +21565,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 183) { + if (languageVersion < 2 && node.kind === 185) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { var decl = variableDeclarationList.declarations[0]; @@ -20622,7 +21583,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 182) { + if (node.kind === 184) { write(" in "); } else { @@ -20633,13 +21594,33 @@ var ts; emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { - var endPos = emitToken(81, node.pos); + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (let _i = 0, _a = expr; _i < _a.length; _i++) { + // let v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 64; - var counter = createTempVariable(node, "_i"); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node); - var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, "_n") : undefined; + var rhsIsIdentifier = node.expression.kind === 65; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(536870912) : undefined; emitStart(node.expression); write("var "); emitNodeWithoutSourceMap(counter); @@ -20683,7 +21664,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -20698,14 +21679,14 @@ var ts; } } else { - emitNodeWithoutSourceMap(createTempVariable(node)); + emitNodeWithoutSourceMap(createTempVariable(0)); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 52, rhsIterationValue, false); - if (node.initializer.kind === 151 || node.initializer.kind === 152) { + var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); + if (node.initializer.kind === 153 || node.initializer.kind === 154) { emitDestructuring(assignmentExpression, true, undefined, node); } else { @@ -20714,7 +21695,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 174) { + if (node.statement.kind === 176) { emitLines(node.statement.statements); } else { @@ -20726,12 +21707,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 185 ? 65 : 70, node.pos); + emitToken(node.kind === 187 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(89, node.pos); + emitToken(90, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -20742,7 +21723,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(91, node.pos); + var endPos = emitToken(92, node.pos); write(" "); emitToken(16, endPos); emit(node.expression); @@ -20759,19 +21740,19 @@ var ts; emitToken(15, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function nodeEndPositionsAreOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, node2.end); + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); } function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 214) { + if (node.kind === 217) { write("case "); emit(node.expression); write(":"); @@ -20806,7 +21787,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(67, node.pos); + var endPos = emitToken(68, node.pos); write(" "); emitToken(16, endPos); emit(node.variableDeclaration); @@ -20815,7 +21796,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(71, node.pos); + emitToken(72, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -20826,18 +21807,24 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 200); + } while (node && node.kind !== 202); return node; } function emitContainingModuleName(node) { var container = getContainingModule(node); - write(container ? resolver.getGeneratedNameForNode(container) : "exports"); + write(container ? getGeneratedNameForNode(container) : "exports"); } function emitModuleMemberName(node) { emitStart(node.name); if (ts.getCombinedNodeFlags(node) & 1) { - emitContainingModuleName(node); - write("."); + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (languageVersion < 2) { + write("exports."); + } } emitNodeWithoutSourceMap(node.name); emitEnd(node.name); @@ -20845,13 +21832,30 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(166); result.expression = zero; return result; } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (node.name) { + emitModuleMemberName(node); + } + else { + write("exports.default"); + } + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + } function emitExportMemberAssignments(name) { - if (!exportDefault && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - ts.forEach(exportSpecifiers[name.text], function (specifier) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text], _c = _b.length; _a < _c; _a++) { + var specifier = _b[_a]; writeLine(); emitStart(specifier.name); emitContainingModuleName(specifier); @@ -20859,15 +21863,15 @@ var ts; emitNodeWithoutSourceMap(specifier.name); emitEnd(specifier.name); write(" = "); - emitNodeWithoutSourceMap(name); + emitExpressionIdentifier(name); write(";"); - }); + } } } function emitDestructuring(root, isAssignmentExpressionStatement, value, lowestNonSynthesizedAncestor) { var emitCount = 0; - var _isDeclaration = (root.kind === 193 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 128; - if (root.kind === 167) { + var isDeclaration = (root.kind === 195 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 129; + if (root.kind === 169) { emitAssignmentExpression(root); } else { @@ -20879,7 +21883,7 @@ var ts; write(", "); } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === 193 || name.parent.kind === 150)) { + if (name.parent && (name.parent.kind === 195 || name.parent.kind === 152)) { emitModuleMemberName(name.parent); } else { @@ -20889,9 +21893,9 @@ var ts; emit(value); } function ensureIdentifier(expr) { - if (expr.kind !== 64) { - var identifier = createTempVariable(lowestNonSynthesizedAncestor || root); - if (!_isDeclaration) { + if (expr.kind !== 65) { + var identifier = createTempVariable(0); + if (!isDeclaration) { recordTempDeclaration(identifier); } emitAssignment(identifier, expr); @@ -20901,14 +21905,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(167); + var equals = ts.createSynthesizedNode(169); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(168); + var cond = ts.createSynthesizedNode(170); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -20922,21 +21926,21 @@ var ts; return node; } function parenthesizeForAccess(expr) { - if (expr.kind === 64 || expr.kind === 153 || expr.kind === 154) { + if (expr.kind === 65 || expr.kind === 155 || expr.kind === 156) { return expr; } - var node = ts.createSynthesizedNode(159); + var node = ts.createSynthesizedNode(161); node.expression = expr; return node; } function createPropertyAccess(object, propName) { - if (propName.kind !== 64) { + if (propName.kind !== 65) { return createElementAccess(object, propName); } return createPropertyAccessExpression(parenthesizeForAccess(object), propName); } function createElementAccess(object, index) { - var node = ts.createSynthesizedNode(154); + var node = ts.createSynthesizedNode(156); node.expression = parenthesizeForAccess(object); node.argumentExpression = index; return node; @@ -20946,9 +21950,9 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value); } - for (var _i = 0, _n = properties.length; _i < _n; _i++) { - var p = properties[_i]; - if (p.kind === 218 || p.kind === 219) { + for (var _a = 0, _b = properties.length; _a < _b; _a++) { + var p = properties[_a]; + if (p.kind === 221 || p.kind === 222) { var propName = (p.name); emitDestructuringAssignment(p.initializer || propName, createPropertyAccess(value, propName)); } @@ -20961,8 +21965,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 172) { - if (e.kind !== 171) { + if (e.kind !== 174) { + if (e.kind !== 173) { emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i))); } else { @@ -20976,14 +21980,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 167 && target.operatorToken.kind === 52) { + if (target.kind === 169 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 152) { + if (target.kind === 154) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 151) { + else if (target.kind === 153) { emitArrayLiteralAssignment(target, value); } else { @@ -20992,19 +21996,19 @@ var ts; } function emitAssignmentExpression(root) { var target = root.left; - var _value = root.right; + var value = root.right; if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, _value); + emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 159) { + if (root.parent.kind !== 161) { write("("); } - _value = ensureIdentifier(_value); - emitDestructuringAssignment(target, _value); + value = ensureIdentifier(value); + emitDestructuringAssignment(target, value); write(", "); - emit(_value); - if (root.parent.kind !== 159) { + emit(value); + if (root.parent.kind !== 161) { write(")"); } } @@ -21024,11 +22028,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 148) { + if (pattern.kind === 150) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccess(value, propName)); } - else if (element.kind !== 172) { + else if (element.kind !== 174) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccess(value, createNumericLiteral(i))); } @@ -21065,8 +22069,8 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 182 && - node.parent.parent.kind !== 183) { + node.parent.parent.kind !== 184 && + node.parent.parent.kind !== 185) { initializer = createVoidZero(); } } @@ -21074,16 +22078,19 @@ var ts; } } function emitExportVariableAssignments(node) { - var _name = node.name; - if (_name.kind === 64) { - emitExportMemberAssignments(_name); + if (node.kind === 174) { + return; } - else if (ts.isBindingPattern(_name)) { - ts.forEach(_name.elements, emitExportVariableAssignments); + var name = node.name; + if (name.kind === 65) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 193 && node.parent.kind !== 150)) { + if (!node.parent || (node.parent.kind !== 195 && node.parent.kind !== 152)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -21091,33 +22098,49 @@ var ts; function renameNonTopLevelLetAndConst(node) { if (languageVersion >= 2 || ts.nodeIsSynthesized(node) || - node.kind !== 64 || - (node.parent.kind !== 193 && node.parent.kind !== 150)) { + node.kind !== 65 || + (node.parent.kind !== 195 && node.parent.kind !== 152)) { return; } var combinedFlags = getCombinedFlagsForIdentifier(node); if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { return; } - var list = ts.getAncestor(node, 194); - if (list.parent.kind === 175 && list.parent.parent.kind === 221) { - return; + var list = ts.getAncestor(node, 196); + if (list.parent.kind === 177) { + var isSourceFileLevelBinding = list.parent.parent.kind === 224; + var isModuleLevelBinding = list.parent.parent.kind === 203; + var isFunctionLevelBinding = list.parent.parent.kind === 176 && ts.isFunctionLike(list.parent.parent.parent); + if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { + return; + } } var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var _parent = blockScopeContainer.kind === 221 + var parent = blockScopeContainer.kind === 224 ? blockScopeContainer : blockScopeContainer.parent; - var generatedName = generateUniqueNameForLocation(_parent, node.text); - var variableId = resolver.getBlockScopedVariableId(node); - if (!generatedBlockScopeNames) { - generatedBlockScopeNames = []; + if (resolver.resolvesToSomeValue(parent, node.text)) { + var variableId = resolver.getBlockScopedVariableId(node); + if (!blockScopedVariableToGeneratedName) { + blockScopedVariableToGeneratedName = []; + } + var generatedName = makeUniqueName(node.text); + blockScopedVariableToGeneratedName[variableId] = generatedName; } - generatedBlockScopeNames[variableId] = generatedName; + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + languageVersion >= 2 && + node.parent.kind === 224; } function emitVariableStatement(node) { if (!(node.flags & 1)) { emitStartOfVariableDeclarationList(node.declarationList); } + else if (isES6ExportedDeclaration(node)) { + write("export "); + emitStartOfVariableDeclarationList(node.declarationList); + } emitCommaList(node.declarationList.declarations); write(";"); if (languageVersion < 2 && node.parent === currentSourceFile) { @@ -21127,12 +22150,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var _name = createTempVariable(node); + var name_16 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(_name); - emit(_name); + tempParameters.push(name_16); + emit(name_16); } else { emit(node.name); @@ -21179,7 +22202,7 @@ var ts; if (languageVersion < 2 && ts.hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; - var tempName = createTempVariable(node, "_i").text; + var tempName = createTempVariable(268435456).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -21214,39 +22237,53 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 134 ? "get " : "set "); - emit(node.name); + write(node.kind === 136 ? "get " : "set "); + emit(node.name, false); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 161 && languageVersion >= 2; + return node.kind === 163 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { emitNodeWithoutSourceMap(node.name); } else { - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 162) { + return !!node.name; + } + else if (node.kind === 197) { + return !!node.name || (languageVersion >= 2 && !(node.flags & 256)); } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 134 && node.kind !== 133) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256) { + write("default "); + } + } write("function "); } - if (node.kind === 195 || (node.kind === 160 && node.name)) { + if (shouldEmitFunctionName(node)) { emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 195 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 197 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 134 && node.kind !== 133) { emitTrailingComments(node); } } @@ -21277,13 +22314,12 @@ var ts; emitSignatureParameters(node); } function emitSignatureAndBody(node) { - var saveTempCount = tempCount; + var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; var saveTempParameters = tempParameters; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; tempParameters = undefined; - var popFrame = enterNameScope(); if (shouldEmitAsArrowFunction(node)) { emitSignatureParametersForArrow(node); write(" =>"); @@ -21294,23 +22330,16 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 174) { + else if (node.body.kind === 176) { emitBlockFunctionBody(node, node.body); } else { emitExpressionFunctionBody(node, node.body); } - if (node.flags & 1 && !(node.flags & 256)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); } - exitNameScope(popFrame); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; } @@ -21326,10 +22355,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 158) { + while (current.kind === 160) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 152); + emitParenthesizedIf(body, current.kind === 154); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -21344,7 +22373,7 @@ var ts; write(" "); emitStart(body); write("return "); - emitWithoutComments(body); + emit(body); emitEnd(body); write(";"); emitTempDeclarations(false); @@ -21355,7 +22384,7 @@ var ts; writeLine(); emitLeadingComments(node.body); write("return "); - emitWithoutComments(node.body); + emit(body); write(";"); emitTrailingComments(node.body); emitTempDeclarations(true); @@ -21378,8 +22407,8 @@ var ts; decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; if (preserveNewLines && !preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _i = 0, _a = body.statements, _n = _a.length; _i < _n; _i++) { - var statement = _a[_i]; + for (var _a = 0, _b = body.statements, _c = _b.length; _a < _c; _a++) { + var statement = _b[_a]; write(" "); emit(statement); } @@ -21401,11 +22430,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 177) { + if (statement && statement.kind === 179) { var expr = statement.expression; - if (expr && expr.kind === 155) { + if (expr && expr.kind === 157) { var func = expr.expression; - if (func && func.kind === 90) { + if (func && func.kind === 91) { return statement; } } @@ -21434,7 +22463,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 126) { + else if (memberName.kind === 127) { emitComputedPropertyName(memberName); } else { @@ -21444,7 +22473,7 @@ var ts; } function emitMemberAssignments(node, staticFlag) { ts.forEach(node.members, function (member) { - if (member.kind === 130 && (member.flags & 128) === staticFlag && member.initializer) { + if (member.kind === 132 && (member.flags & 128) === staticFlag && member.initializer) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -21465,20 +22494,17 @@ var ts; } }); } - function emitMemberFunctions(node) { + function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 132 || node.kind === 131) { + if (member.kind === 134 || node.kind === 133) { if (!member.body) { - return emitPinnedOrTripleSlashComments(member); + return emitOnlyPinnedOrTripleSlashComments(member); } writeLine(); emitLeadingComments(member); emitStart(member); emitStart(member.name); - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); @@ -21489,17 +22515,14 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 134 || member.kind === 135) { - var accessors = getAllAccessorDeclarations(node.members, member); + else if (member.kind === 136 || member.kind === 137) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); emitStart(member); write("Object.defineProperty("); emitStart(member.name); - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); @@ -21539,7 +22562,207 @@ var ts; } }); } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members, _c = _b.length; _a < _c; _a++) { + var member = _b[_a]; + if ((member.kind === 134 || node.kind === 133) && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + else if (member.kind === 134 || node.kind === 133 || member.kind === 136 || member.kind === 137) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 136) { + write("get "); + } + else if (member.kind === 137) { + write("set "); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + } + } + function emitConstructor(node, baseTypeNode) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 135 && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + if (member.kind === 132 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeNode) { + write("(...args)"); + } + else { + write("()"); + } + } + } + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeNode) { + var superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeNode); + } + } + emitMemberAssignments(node, 0); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLines(statements); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } function emitClassDeclaration(node) { + if (languageVersion < 2) { + emitClassDeclarationBelowES6(node); + } + else { + emitClassDeclarationForES6AndHigher(node); + } + } + function emitClassDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256) { + write("default "); + } + } + write("class"); + if ((node.name || !(node.flags & 256)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.typeName); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(15, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + if (node.name) { + writeLine(); + write("Object.defineProperty("); + emitDeclarationName(node); + write(", \"name\", { value: \""); + emitDeclarationName(node); + write("\", configurable: true });"); + writeLine(); + } + } + writeLine(); + emitMemberAssignments(node, 128); + emitDecoratorsOfClass(node); + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 256) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassDeclarationBelowES6(node) { write("var "); emitDeclarationName(node); write(" = (function ("); @@ -21548,6 +22771,14 @@ var ts; write("_super"); } write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; increaseIndent(); scopeEmitStart(node); if (baseTypeNode) { @@ -21559,15 +22790,22 @@ var ts; emitEnd(baseTypeNode); } writeLine(); - emitConstructorOfClass(); - emitMemberFunctions(node); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); emitMemberAssignments(node, 128); writeLine(); + emitDecoratorsOfClass(node); + writeLine(); emitToken(15, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); emitToken(15, node.members.end); @@ -21579,94 +22817,147 @@ var ts; } write(");"); emitEnd(node); - if (node.flags & 1 && !(node.flags & 256)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } + emitExportMemberAssignment(node); if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - function emitConstructorOfClass() { - var saveTempCount = tempCount; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempCount = 0; - tempVariables = undefined; - tempParameters = undefined; - var popFrame = enterNameScope(); - ts.forEach(node.members, function (member) { - if (member.kind === 133 && !member.body) { - emitPinnedOrTripleSlashComments(member); - } - }); - var ctor = getFirstConstructorWithBody(node); - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeNode) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("_super.apply(this, arguments);"); - emitEnd(baseTypeNode); - } - } - emitMemberAssignments(node, 0); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) - statements = statements.slice(1); - emitLines(statements); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - exitNameScope(popFrame); - tempCount = saveTempCount; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); } } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var constructor = ts.getFirstConstructorWithBody(node); + if (constructor) { + emitDecoratorsOfParameters(node, constructor); + } + if (!ts.nodeIsDecorated(node)) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = "); + emitDecorateStart(node.decorators); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + ts.forEach(node.members, function (member) { + if ((member.flags & 128) !== staticFlag) { + return; + } + var decorators; + switch (member.kind) { + case 134: + emitDecoratorsOfParameters(node, member); + decorators = member.decorators; + break; + case 136: + case 137: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + return; + } + if (accessors.setAccessor) { + emitDecoratorsOfParameters(node, accessors.setAccessor); + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + break; + case 132: + decorators = member.decorators; + break; + default: + return; + } + if (!decorators) { + return; + } + writeLine(); + emitStart(member); + if (member.kind !== 132) { + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", "); + } + emitDecorateStart(decorators); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (member.kind !== 132) { + write(", Object.getOwnPropertyDescriptor("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write("))"); + } + write(");"); + emitEnd(member); + writeLine(); + }); + } + function emitDecoratorsOfParameters(node, member) { + ts.forEach(member.parameters, function (parameter, parameterIndex) { + if (!ts.nodeIsDecorated(parameter)) { + return; + } + writeLine(); + emitStart(parameter); + emitDecorateStart(parameter.decorators); + emitStart(parameter.name); + if (member.kind === 135) { + emitDeclarationName(node); + write(", void 0"); + } + else { + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + } + write(", "); + write(String(parameterIndex)); + emitEnd(parameter.name); + write(");"); + emitEnd(parameter); + writeLine(); + }); + } + function emitDecorateStart(decorators) { + write("__decorate(["); + var decoratorCount = decorators.length; + for (var i = 0; i < decoratorCount; i++) { + if (i > 0) { + write(", "); + } + var decorator = decorators[i]; + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + } + write("], "); + } function emitInterfaceDeclaration(node) { - emitPinnedOrTripleSlashComments(node); + emitOnlyPinnedOrTripleSlashComments(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -21676,8 +22967,11 @@ var ts; if (!shouldEmitEnumDeclaration(node)) { return; } - if (!(node.flags & 1)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); emitEnd(node); @@ -21687,7 +22981,7 @@ var ts; emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") {"); increaseIndent(); @@ -21703,7 +22997,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (node.flags & 1) { + if (!isES6ExportedDeclaration(node) && node.flags & 1) { writeLine(); emitStart(node); write("var "); @@ -21720,9 +23014,9 @@ var ts; function emitEnumMember(node) { var enumParent = node.parent; emitStart(node); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); emitExpressionForPropertyName(node.name); write("] = "); @@ -21733,14 +23027,12 @@ var ts; write(";"); } function writeEnumMemberDeclarationValue(member) { - if (!member.initializer || ts.isConst(member.parent)) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; } - if (member.initializer) { + else if (member.initializer) { emit(member.initializer); } else { @@ -21748,7 +23040,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 200) { + if (moduleDeclaration.body.kind === 202) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -21759,9 +23051,12 @@ var ts; function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); write(";"); @@ -21770,18 +23065,16 @@ var ts; emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 201) { - var saveTempCount = tempCount; + if (node.body.kind === 203) { + var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; - var popFrame = enterNameScope(); emit(node.body); - exitNameScope(popFrame); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; } else { @@ -21798,7 +23091,7 @@ var ts; scopeEmitEnd(); } write(")("); - if (node.flags & 1) { + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -21807,7 +23100,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (languageVersion < 2 && node.name.kind === 64 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 65 && node.parent === currentSourceFile) { emitExportMemberAssignments(node.name); } } @@ -21818,199 +23111,303 @@ var ts; emitLiteral(moduleName); emitEnd(moduleName); emitToken(17, moduleName.end); - write(";"); } else { - write("require();"); + write("require()"); } } + function getNamespaceDeclarationNode(node) { + if (node.kind === 205) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 208) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 206 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } function emitImportDeclaration(node) { - var info = getExternalImportInfo(node); - if (info) { - var declarationNode = info.declarationNode; - var namedImports = info.namedImports; + if (languageVersion < 2) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 208) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 205 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); emitStart(node); - var moduleName = ts.getExternalModuleName(node); - if (declarationNode) { - if (!(declarationNode.flags & 1)) + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) write("var "); - emitModuleMemberName(declarationNode); + emitModuleMemberName(namespaceDeclaration); write(" = "); - emitRequire(moduleName); - } - else if (namedImports) { - write("var "); - write(resolver.getGeneratedNameForNode(node)); - write(" = "); - emitRequire(moduleName); } else { - emitRequire(moduleName); + var isNakedImport = 206 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } else { - if (declarationNode) { - if (declarationNode.flags & 1) { - emitModuleMemberName(declarationNode); - write(" = "); - emit(declarationNode.name); - write(";"); - } + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); } } } function emitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitImportDeclaration(node); + emitExternalImportDeclaration(node); return; } if (resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (!(node.flags & 1)) + if (isES6ExportedDeclaration(node)) { + write("export "); write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } } function emitExportDeclaration(node) { - if (node.moduleSpecifier) { - emitStart(node); - var generatedName = resolver.getGeneratedNameForNode(node); - if (compilerOptions.module !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - } - if (node.exportClause) { - ts.forEach(node.exportClause.elements, function (specifier) { + if (languageVersion < 2) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (compilerOptions.module !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements, _c = _b.length; _a < _c; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write("__export("); + if (compilerOptions.module !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + emitStart(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emitNodeWithoutSourceMap(node.moduleSpecifier); + } + write(";"); + emitEnd(node); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(languageVersion >= 2); + var needsComma = false; + for (var _a = 0, _b = specifiers.length; _a < _b; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + emitStart(specifier); + if (specifier.propertyName) { + emitNodeWithoutSourceMap(specifier.propertyName); + write(" as "); + } + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (languageVersion >= 2) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 197 && + expression.kind !== 198) { write(";"); - emitEnd(specifier); - }); + } + emitEnd(node); } else { - var tempName = createTempVariable(node).text; writeLine(); - write("for (var " + tempName + " in " + generatedName + ") if (!"); + emitStart(node); emitContainingModuleName(node); - write(".hasOwnProperty(" + tempName + ")) "); - emitContainingModuleName(node); - write("[" + tempName + "] = " + generatedName + "[" + tempName + "];"); - } - emitEnd(node); - } - } - function createExternalImportInfo(node) { - if (node.kind === 203) { - if (node.moduleReference.kind === 213) { - return { - rootNode: node, - declarationNode: node - }; - } - } - else if (node.kind === 204) { - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - return { - rootNode: node, - declarationNode: importClause - }; - } - if (importClause.namedBindings.kind === 206) { - return { - rootNode: node, - declarationNode: importClause.namedBindings - }; - } - return { - rootNode: node, - namedImports: importClause.namedBindings, - localName: resolver.getGeneratedNameForNode(node) - }; - } - return { - rootNode: node - }; - } - else if (node.kind === 210) { - if (node.moduleSpecifier) { - return { - rootNode: node - }; + write(".default = "); + emit(node.expression); + write(";"); + emitEnd(node); } } } - function createExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile) { externalImports = []; exportSpecifiers = {}; - exportDefault = undefined; - ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 210 && !node.moduleSpecifier) { - ts.forEach(node.exportClause.elements, function (specifier) { - if (specifier.name.text === "default") { - exportDefault = exportDefault || specifier; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements, _c = _b.length; _a < _c; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 206: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); } - var _name = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[_name] || (exportSpecifiers[_name] = [])).push(specifier); - }); - } - else if (node.kind === 209) { - exportDefault = exportDefault || node; - } - else if (node.kind === 195 || node.kind === 196) { - if (node.flags & 1 && node.flags & 256) { - exportDefault = exportDefault || node; - } - } - else { - var info = createExternalImportInfo(node); - if (info) { - if ((!info.declarationNode && !info.namedImports) || resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(info); + break; + case 205: + if (node.moduleReference.kind === 216 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); } - } - } - }); - } - function getExternalImportInfo(node) { - if (externalImports) { - for (var _i = 0, _n = externalImports.length; _i < _n; _i++) { - var info = externalImports[_i]; - if (info.rootNode === node) { - return info; - } + break; + case 212: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _d = 0, _e = node.exportClause.elements, _f = _e.length; _d < _f; _d++) { + var specifier = _e[_d]; + var name_17 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_17] || (exportSpecifiers[name_17] = [])).push(specifier); + } + } + break; + case 211: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; } } } - function getFirstExportAssignment(sourceFile) { - return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 209) { - return node; - } - }); - } function sortAMDModules(amdModules) { return amdModules.sort(function (moduleA, moduleB) { if (moduleA.name === moduleB.name) { @@ -22024,7 +23421,20 @@ var ts; } }); } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); writeLine(); write("define("); sortAMDModules(node.amdDependencies); @@ -22032,69 +23442,78 @@ var ts; write("\"" + node.amdModuleName + "\", "); } write("[\"require\", \"exports\""); - ts.forEach(externalImports, function (info) { + for (var _a = 0, _b = externalImports.length; _a < _b; _a++) { + var importNode = externalImports[_a]; write(", "); - var moduleName = ts.getExternalModuleName(info.rootNode); + var moduleName = ts.getExternalModuleName(importNode); if (moduleName.kind === 8) { emitLiteral(moduleName); } else { write("\"\""); } - }); - ts.forEach(node.amdDependencies, function (amdDependency) { + } + for (var _c = 0, _d = node.amdDependencies, _e = _d.length; _c < _e; _c++) { + var amdDependency = _d[_c]; var text = "\"" + amdDependency.path + "\""; write(", "); write(text); - }); + } write("], function (require, exports"); - ts.forEach(externalImports, function (info) { + for (var _f = 0, _g = externalImports.length; _f < _g; _f++) { + var importNode = externalImports[_f]; write(", "); - if (info.declarationNode) { - emit(info.declarationNode.name); + var namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + emit(namespaceDeclaration.name); } else { - write(resolver.getGeneratedNameForNode(info.rootNode)); + write(getGeneratedNameForNode(importNode)); } - }); - ts.forEach(node.amdDependencies, function (amdDependency) { + } + for (var _h = 0, _j = node.amdDependencies, _k = _j.length; _h < _k; _h++) { + var amdDependency = _j[_h]; if (amdDependency.name) { write(", "); write(amdDependency.name); } - }); + } write(") {"); increaseIndent(); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - emitExportDefault(node, true); + emitExportEquals(true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + collectExternalModuleInfo(node); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - emitExportDefault(node, false); + emitExportEquals(false); } - function emitExportDefault(sourceFile, emitAsReturn) { - if (exportDefault && resolver.hasExportDefaultValue(sourceFile)) { + function emitES6Module(node, startIndex) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { writeLine(); - emitStart(exportDefault); + emitStart(exportEquals); write(emitAsReturn ? "return " : "module.exports = "); - if (exportDefault.kind === 209) { - emit(exportDefault.expression); - } - else if (exportDefault.kind === 212) { - emit(exportDefault.propertyName); - } - else { - emitDeclarationName(exportDefault); - } + emit(exportEquals.expression); write(";"); - emitEnd(exportDefault); + emitEnd(exportEquals); } } function emitDirectivePrologues(statements, startWithNewLine) { @@ -22111,11 +23530,21 @@ var ts; } return statements.length; } + function writeHelper(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } function emitSourceFileNode(node) { writeLine(); emitDetachedComments(node); var startIndex = emitDirectivePrologues(node.statements, false); - if (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLine(); write("var __extends = this.__extends || function (d, b) {"); increaseIndent(); @@ -22132,9 +23561,15 @@ var ts; write("};"); extendsEmitted = true; } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { + writeHelper("\nvar __decorate = this.__decorate || function (decorators, target, key, value) {\n var kind = typeof (arguments.length == 2 ? value = target : value);\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n switch (kind) {\n case \"function\": value = decorator(value) || value; break;\n case \"number\": decorator(target, key, value); break;\n case \"undefined\": decorator(target, key); break;\n case \"object\": value = decorator(target, key, value) || value; break;\n }\n }\n return value;\n};"); + decorateEmitted = true; + } if (ts.isExternalModule(node)) { - createExternalModuleInfo(node); - if (compilerOptions.module === 2) { + if (languageVersion >= 2) { + emitES6Module(node, startIndex); + } + else if (compilerOptions.module === 2) { emitAMDModule(node, startIndex); } else { @@ -22144,75 +23579,75 @@ var ts; else { externalImports = undefined; exportSpecifiers = undefined; - exportDefault = undefined; + exportEquals = undefined; + hasExportStars = false; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMapWithComments(node) { + function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { if (!node) { return; } if (node.flags & 2) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } - var _emitComments = shouldEmitLeadingAndTrailingComments(node); - if (_emitComments) { + var emitComments = shouldEmitLeadingAndTrailingComments(node); + if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node); - if (_emitComments) { + emitJavaScriptWorker(node, allowGeneratedIdentifiers); + if (emitComments) { emitTrailingComments(node); } } - function emitNodeWithoutSourceMapWithoutComments(node) { - if (!node) { - return; - } - if (node.flags & 2) { - return emitPinnedOrTripleSlashComments(node); - } - emitJavaScriptWorker(node); - } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 197: - case 195: - case 204: - case 203: - case 198: - case 209: - return false; - case 200: - return shouldEmitModuleDeclaration(node); case 199: + case 197: + case 206: + case 205: + case 200: + case 211: + return false; + case 202: + return shouldEmitModuleDeclaration(node); + case 201: return shouldEmitEnumDeclaration(node); } + if (node.kind !== 176 && + node.parent && + node.parent.kind === 163 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } return true; } - function emitJavaScriptWorker(node) { + function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } switch (node.kind) { - case 64: - return emitIdentifier(node); - case 128: + case 65: + return emitIdentifier(node, allowGeneratedIdentifiers); + case 129: return emitParameter(node); - case 132: - case 131: - return emitMethod(node); case 134: - case 135: + case 133: + return emitMethod(node); + case 136: + case 137: return emitAccessor(node); - case 92: + case 93: return emitThis(node); - case 90: + case 91: return emitSuper(node); - case 88: + case 89: return write("null"); - case 94: + case 95: return write("true"); - case 79: + case 80: return write("false"); case 7: case 8: @@ -22222,125 +23657,127 @@ var ts; case 12: case 13: return emitLiteral(node); - case 169: - return emitTemplateExpression(node); - case 173: - return emitTemplateSpan(node); - case 125: - return emitQualifiedName(node); - case 148: - return emitObjectBindingPattern(node); - case 149: - return emitArrayBindingPattern(node); - case 150: - return emitBindingElement(node); - case 151: - return emitArrayLiteral(node); - case 152: - return emitObjectLiteral(node); - case 218: - return emitPropertyAssignment(node); - case 219: - return emitShorthandPropertyAssignment(node); - case 126: - return emitComputedPropertyName(node); - case 153: - return emitPropertyAccess(node); - case 154: - return emitIndexedAccess(node); - case 155: - return emitCallExpression(node); - case 156: - return emitNewExpression(node); - case 157: - return emitTaggedTemplateExpression(node); - case 158: - return emit(node.expression); - case 159: - return emitParenExpression(node); - case 195: - case 160: - case 161: - return emitFunctionDeclaration(node); - case 162: - return emitDeleteExpression(node); - case 163: - return emitTypeOfExpression(node); - case 164: - return emitVoidExpression(node); - case 165: - return emitPrefixUnaryExpression(node); - case 166: - return emitPostfixUnaryExpression(node); - case 167: - return emitBinaryExpression(node); - case 168: - return emitConditionalExpression(node); case 171: - return emitSpreadElementExpression(node); - case 172: - return; - case 174: - case 201: - return emitBlock(node); + return emitTemplateExpression(node); case 175: - return emitVariableStatement(node); - case 176: - return write(";"); - case 177: - return emitExpressionStatement(node); - case 178: - return emitIfStatement(node); - case 179: - return emitDoStatement(node); - case 180: - return emitWhileStatement(node); - case 181: - return emitForStatement(node); - case 183: - case 182: - return emitForInOrForOfStatement(node); - case 184: - case 185: - return emitBreakOrContinueStatement(node); - case 186: - return emitReturnStatement(node); - case 187: - return emitWithStatement(node); - case 188: - return emitSwitchStatement(node); - case 214: - case 215: - return emitCaseOrDefaultClause(node); - case 189: - return emitLabelledStatement(node); - case 190: - return emitThrowStatement(node); - case 191: - return emitTryStatement(node); - case 217: - return emitCatchClause(node); - case 192: - return emitDebuggerStatement(node); - case 193: - return emitVariableDeclaration(node); - case 196: - return emitClassDeclaration(node); - case 197: - return emitInterfaceDeclaration(node); - case 199: - return emitEnumDeclaration(node); - case 220: - return emitEnumMember(node); - case 200: - return emitModuleDeclaration(node); - case 204: - return emitImportDeclaration(node); - case 203: - return emitImportEqualsDeclaration(node); - case 210: - return emitExportDeclaration(node); + return emitTemplateSpan(node); + case 126: + return emitQualifiedName(node); + case 150: + return emitObjectBindingPattern(node); + case 151: + return emitArrayBindingPattern(node); + case 152: + return emitBindingElement(node); + case 153: + return emitArrayLiteral(node); + case 154: + return emitObjectLiteral(node); case 221: + return emitPropertyAssignment(node); + case 222: + return emitShorthandPropertyAssignment(node); + case 127: + return emitComputedPropertyName(node); + case 155: + return emitPropertyAccess(node); + case 156: + return emitIndexedAccess(node); + case 157: + return emitCallExpression(node); + case 158: + return emitNewExpression(node); + case 159: + return emitTaggedTemplateExpression(node); + case 160: + return emit(node.expression); + case 161: + return emitParenExpression(node); + case 197: + case 162: + case 163: + return emitFunctionDeclaration(node); + case 164: + return emitDeleteExpression(node); + case 165: + return emitTypeOfExpression(node); + case 166: + return emitVoidExpression(node); + case 167: + return emitPrefixUnaryExpression(node); + case 168: + return emitPostfixUnaryExpression(node); + case 169: + return emitBinaryExpression(node); + case 170: + return emitConditionalExpression(node); + case 173: + return emitSpreadElementExpression(node); + case 174: + return; + case 176: + case 203: + return emitBlock(node); + case 177: + return emitVariableStatement(node); + case 178: + return write(";"); + case 179: + return emitExpressionStatement(node); + case 180: + return emitIfStatement(node); + case 181: + return emitDoStatement(node); + case 182: + return emitWhileStatement(node); + case 183: + return emitForStatement(node); + case 185: + case 184: + return emitForInOrForOfStatement(node); + case 186: + case 187: + return emitBreakOrContinueStatement(node); + case 188: + return emitReturnStatement(node); + case 189: + return emitWithStatement(node); + case 190: + return emitSwitchStatement(node); + case 217: + case 218: + return emitCaseOrDefaultClause(node); + case 191: + return emitLabelledStatement(node); + case 192: + return emitThrowStatement(node); + case 193: + return emitTryStatement(node); + case 220: + return emitCatchClause(node); + case 194: + return emitDebuggerStatement(node); + case 195: + return emitVariableDeclaration(node); + case 198: + return emitClassDeclaration(node); + case 199: + return emitInterfaceDeclaration(node); + case 201: + return emitEnumDeclaration(node); + case 223: + return emitEnumMember(node); + case 202: + return emitModuleDeclaration(node); + case 206: + return emitImportDeclaration(node); + case 205: + return emitImportEqualsDeclaration(node); + case 212: + return emitExportDeclaration(node); + case 211: + return emitExportAssignment(node); + case 224: return emitSourceFileNode(node); } } @@ -22357,34 +23794,50 @@ var ts; } return leadingComments; } + function filterComments(ranges, onlyPinnedOrTripleSlashComments) { + if (ranges && onlyPinnedOrTripleSlashComments) { + ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); + if (ranges.length === 0) { + return undefined; + } + } + return ranges; + } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 221 || node.pos !== node.parent.pos) { - var leadingComments; + if (node.parent.kind === 224 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); + return getLeadingCommentsWithoutDetachedComments(); } else { - leadingComments = ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); } - return leadingComments; } } } - function emitLeadingDeclarationComments(node) { - var leadingComments = getLeadingCommentsToEmit(node); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingDeclarationComments(node) { + function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 221 || node.end !== node.parent.end) { - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + if (node.parent.kind === 224 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitLeadingCommentsOfLocalPosition(pos) { + function emitOnlyPinnedOrTripleSlashComments(node) { + emitLeadingCommentsWorker(node, true); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + } + function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { + var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitLeadingCommentsOfPosition(pos) { var leadingComments; if (hasDetachedComments(pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -22392,18 +23845,19 @@ var ts; else { leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + leadingComments = filterComments(leadingComments, compilerOptions.removeComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } - function emitDetachedCommentsAtPosition(node) { + function emitDetachedComments(node) { var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); if (leadingComments) { var detachedComments = []; var lastComment; ts.forEach(leadingComments, function (comment) { if (lastComment) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); if (commentLine >= lastCommentLine + 2) { return detachedComments; } @@ -22412,11 +23866,11 @@ var ts; lastComment = comment; }); if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); - var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -22428,54 +23882,53 @@ var ts; } } } - function emitPinnedOrTripleSlashComments(node) { - var pinnedComments = ts.filter(getLeadingCommentsToEmit(node), isPinnedOrTripleSlashComment); - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; - } + function isPinnedOrTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && + currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { + return true; } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments); - emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment); - } - } - function writeDeclarationFile(jsFilePath, sourceFile) { - var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput; - var appliedSyncOutputPos = 0; - ts.forEach(emitDeclarationResult.aliasDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += aliasEmitInfo.asynchronousOutput; - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos); - writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); if (compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); } } } ts.emitFiles = emitFiles; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { + ts.programTime = 0; ts.emitTime = 0; ts.ioReadTime = 0; + ts.ioWriteTime = 0; ts.version = "1.5.0.0"; - function createCompilerHost(options) { + function findConfigFile(searchPath) { + var fileName = "tsconfig.json"; + while (true) { + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; function getCanonicalFileName(fileName) { @@ -22497,29 +23950,31 @@ var ts; } text = ""; } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined; + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } } function writeFile(fileName, data, writeByteOrderMark, onError) { - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } try { + var start = new Date().getTime(); ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); ts.sys.writeFile(fileName, data, writeByteOrderMark); + ts.ioWriteTime += new Date().getTime() - start; } catch (e) { if (onError) { @@ -22540,6 +23995,9 @@ var ts; ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program) { var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics()); + } return ts.sortAndDeduplicateDiagnostics(diagnostics); } ts.getPreEmitDiagnostics = getPreEmitDiagnostics; @@ -22573,14 +24031,16 @@ var ts; var diagnostics = ts.createDiagnosticCollection(); var seenNoDefaultLib = options.noLib; var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var start = new Date().getTime(); host = host || createCompilerHost(options); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); if (!seenNoDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; + ts.programTime += new Date().getTime() - start; program = { getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, @@ -22618,10 +24078,6 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function getDeclarationDiagnostics(targetSourceFile) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(targetSourceFile); - return ts.getDeclarationDiagnostics(getEmitHost(), resolver, targetSourceFile); - } function emit(sourceFile, writeFileCallback) { if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; @@ -22652,6 +24108,9 @@ var ts; function getSemanticDiagnostics(sourceFile) { return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); } + function getDeclarationDiagnostics(sourceFile) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + } function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } @@ -22663,6 +24122,13 @@ var ts; var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); } + function getDeclarationDiagnosticsForFile(sourceFile) { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + var writeFile = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + } + } function getGlobalDiagnostics() { var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; @@ -22678,10 +24144,10 @@ var ts; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var start; - var _length; + var length; if (refEnd !== undefined && refPos !== undefined) { start = refPos; - _length = refEnd - refPos; + length = refEnd - refPos; } var diagnostic; if (hasExtension(fileName)) { @@ -22706,7 +24172,7 @@ var ts; } if (diagnostic) { if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, start, _length, diagnostic, fileName)); + diagnostics.add(ts.createFileDiagnostic(refFile, start, length, diagnostic, fileName)); } else { diagnostics.add(ts.createCompilerDiagnostic(diagnostic, fileName)); @@ -22750,14 +24216,14 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var _file = filesByName[canonicalName]; - if (_file && host.useCaseSensitiveFileNames()) { - var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(_file.fileName, host.getCurrentDirectory()) : _file.fileName; + var file = filesByName[canonicalName]; + if (file && host.useCaseSensitiveFileNames()) { + var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } } - return _file; + return file; } } function processReferencedFiles(file, basePath) { @@ -22768,7 +24234,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 204 || node.kind === 203 || node.kind === 210) { + if (node.kind === 206 || node.kind === 205 || node.kind === 212) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -22788,17 +24254,17 @@ var ts; } } } - else if (node.kind === 200 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 202 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { - var _searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - var tsFile = findModuleSourceFile(_searchName + ".ts", nameLiteral); + var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); + var tsFile = findModuleSourceFile(searchName + ".ts", nameLiteral); if (!tsFile) { - findModuleSourceFile(_searchName + ".d.ts", nameLiteral); + findModuleSourceFile(searchName + ".d.ts", nameLiteral); } } } @@ -22819,10 +24285,16 @@ var ts; } return; } + var languageVersion = options.target || 0; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (firstExternalModuleSourceFile && !options.module) { - var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + if (!options.module && languageVersion < 2) { + var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + } + } + if (options.module && languageVersion >= 2) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); } if (options.outDir || options.sourceRoot || @@ -22871,6 +24343,10 @@ var ts; } ts.createProgram = createProgram; })(ts || (ts = {})); +/// +/// +/// +/// var ts; (function (ts) { ts.optionDeclarations = [ @@ -23221,6 +24697,20 @@ var ts; } ts.parseConfigFile = parseConfigFile; })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// var ts; (function (ts) { var OutliningElementsCollector; @@ -23240,7 +24730,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 161; + return ts.isFunctionBlock(node) && node.parent.kind !== 163; } var depth = 0; var maxDepth = 20; @@ -23249,30 +24739,30 @@ var ts; return; } switch (n.kind) { - case 174: + case 176: if (!ts.isFunctionBlock(n)) { - var _parent = n.parent; + var parent_6 = n.parent; var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (_parent.kind === 179 || - _parent.kind === 182 || - _parent.kind === 183 || - _parent.kind === 181 || - _parent.kind === 178 || - _parent.kind === 180 || - _parent.kind === 187 || - _parent.kind === 217) { - addOutliningSpan(_parent, openBrace, closeBrace, autoCollapse(n)); + if (parent_6.kind === 181 || + parent_6.kind === 184 || + parent_6.kind === 185 || + parent_6.kind === 183 || + parent_6.kind === 180 || + parent_6.kind === 182 || + parent_6.kind === 189 || + parent_6.kind === 220) { + addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } - if (_parent.kind === 191) { - var tryStatement = _parent; + if (parent_6.kind === 193) { + var tryStatement = parent_6; if (tryStatement.tryBlock === n) { - addOutliningSpan(_parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 80, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 81, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -23288,23 +24778,23 @@ var ts; }); break; } - case 201: { - var _openBrace = ts.findChildOfKind(n, 14, sourceFile); - var _closeBrace = ts.findChildOfKind(n, 15, sourceFile); - addOutliningSpan(n.parent, _openBrace, _closeBrace, autoCollapse(n)); + case 203: { + var openBrace = ts.findChildOfKind(n, 14, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 196: - case 197: + case 198: case 199: - case 152: - case 202: { - var _openBrace_1 = ts.findChildOfKind(n, 14, sourceFile); - var _closeBrace_1 = ts.findChildOfKind(n, 15, sourceFile); - addOutliningSpan(n, _openBrace_1, _closeBrace_1, autoCollapse(n)); + case 201: + case 154: + case 204: { + var openBrace = ts.findChildOfKind(n, 14, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 151: + case 153: var openBracket = ts.findChildOfKind(n, 18, sourceFile); var closeBracket = ts.findChildOfKind(n, 19, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -23375,9 +24865,9 @@ var ts; if (result !== undefined) { return result; } - if (declaration.name.kind === 126) { + if (declaration.name.kind === 127) { var expr = declaration.name.expression; - if (expr.kind === 153) { + if (expr.kind === 155) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -23385,7 +24875,7 @@ var ts; return undefined; } function getTextOfIdentifierOrLiteral(node) { - if (node.kind === 64 || + if (node.kind === 65 || node.kind === 8 || node.kind === 7) { return node.text; @@ -23398,7 +24888,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 126) { + else if (declaration.name.kind === 127) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -23415,7 +24905,7 @@ var ts; } return true; } - if (expression.kind === 153) { + if (expression.kind === 155) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -23426,7 +24916,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 126) { + if (declaration.name.kind === 127) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -23442,15 +24932,15 @@ var ts; } function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); - var _bestMatchKind = 3; + var bestMatchKind = ts.PatternMatchKind.camelCase; for (var _i = 0, _n = matches.length; _i < _n; _i++) { var match = matches[_i]; var kind = match.kind; - if (kind < _bestMatchKind) { - _bestMatchKind = kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; } } - return _bestMatchKind; + return bestMatchKind; } var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { @@ -23477,6 +24967,7 @@ var ts; NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { var NavigationBar; @@ -23489,14 +24980,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 200: + case 202: do { current = current.parent; - } while (current.kind === 200); - case 196: + } while (current.kind === 202); + case 198: + case 201: case 199: case 197: - case 195: indent++; } current = current.parent; @@ -23507,26 +24998,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 175: + case 177: ts.forEach(node.declarationList.declarations, visit); break; - case 148: - case 149: + case 150: + case 151: ts.forEach(node.elements, visit); break; - case 210: + case 212: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 204: + case 206: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { childNodes.push(importClause.namedBindings); } else { @@ -23535,20 +25026,20 @@ var ts; } } break; - case 150: - case 193: + case 152: + case 195: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 196: + case 198: + case 201: case 199: + case 202: case 197: - case 200: - case 195: - case 203: - case 208: - case 212: + case 205: + case 210: + case 214: childNodes.push(node); break; } @@ -23583,17 +25074,17 @@ var ts; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var node = nodes[_i]; switch (node.kind) { - case 196: + case 198: + case 201: case 199: - case 197: topLevelNodes.push(node); break; - case 200: + case 202: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 195: + case 197: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -23604,9 +25095,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 195) { - if (functionDeclaration.body && functionDeclaration.body.kind === 174) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 195 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 197) { + if (functionDeclaration.body && functionDeclaration.body.kind === 176) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 197 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -23621,17 +25112,17 @@ var ts; var keyToItem = {}; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var child = nodes[_i]; - var _item = createItem(child); - if (_item !== undefined) { - if (_item.text.length > 0) { - var key = _item.text + "-" + _item.kind + "-" + _item.indent; + var item_3 = createItem(child); + if (item_3 !== undefined) { + if (item_3.text.length > 0) { + var key = item_3.text + "-" + item_3.kind + "-" + item_3.indent; var itemWithSameName = keyToItem[key]; if (itemWithSameName) { - merge(itemWithSameName, _item); + merge(itemWithSameName, item_3); } else { - keyToItem[key] = _item; - items.push(_item); + keyToItem[key] = item_3; + items.push(item_3); } } } @@ -23659,7 +25150,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 128: + case 129: if (ts.isBindingPattern(node.name)) { break; } @@ -23667,34 +25158,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 134: + case 133: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 136: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 137: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 140: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 223: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 138: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 139: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); case 132: case 131: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 134: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 135: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 138: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 220: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 136: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 137: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 130: - case 129: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 195: + case 197: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 193: - case 150: + case 195: + case 152: var variableDeclarationNode; - var _name; - if (node.kind === 150) { - _name = node.name; + var name_18; + if (node.kind === 152) { + name_18 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 193) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 195) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -23702,24 +25193,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - _name = node.name; + name_18 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.variableElement); } - case 133: + case 135: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 212: - case 208: - case 203: + case 214: + case 210: case 205: - case 206: + case 207: + case 208: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -23749,17 +25240,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 221: + case 224: return createSourceFileItem(node); - case 196: + case 198: return createClassItem(node); - case 199: + case 201: return createEnumItem(node); - case 197: + case 199: return createIterfaceItem(node); - case 200: + case 202: return createModuleItem(node); - case 195: + case 197: return createFunctionItem(node); } return undefined; @@ -23769,7 +25260,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 200) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 202) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -23781,9 +25272,9 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.name && node.body && node.body.kind === 174) { + if ((node.name || node.flags & 256) && node.body && node.body.kind === 176) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + return getNavigationBarItem((!node.name && node.flags & 256) ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } return undefined; } @@ -23799,13 +25290,10 @@ var ts; return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); } function createClassItem(node) { - if (!node.name) { - return undefined; - } var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 133 && member; + return member.kind === 135 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -23813,7 +25301,8 @@ var ts; } childItems = getItemsWorker(sortNodes(nodes), createChildItem); } - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + var nodeName = !node.name && (node.flags & 256) ? "default" : node.name.text; + return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createEnumItem(node) { var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); @@ -23825,19 +25314,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 126; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 127; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 200) { + while (node.body.kind === 202) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 221 + return node.kind === 224 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -23919,10 +25408,10 @@ var ts; var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); if (index === 0) { if (chunk.text.length === candidate.length) { - return createPatternMatch(0, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); } else { - return createPatternMatch(1, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -23932,14 +25421,14 @@ var ts; for (var _i = 0, _n = wordSpans.length; _i < _n; _i++) { var span = wordSpans[_i]; if (partStartsWith(candidate, span, chunk.text, true)) { - return createPatternMatch(2, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); } } } } else { if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(2, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); } } if (!isLowercase) { @@ -23947,18 +25436,18 @@ var ts; var candidateParts = getWordSpans(candidate); var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); if (camelCaseWeight !== undefined) { - return createPatternMatch(3, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); } camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); if (camelCaseWeight !== undefined) { - return createPatternMatch(3, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); } } } if (isLowercase) { if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(2, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); } } } @@ -24009,10 +25498,10 @@ var ts; } } else { - for (var _i = 0; _i < patternPartLength; _i++) { - var _ch1 = pattern.charCodeAt(patternPartStart + _i); - var _ch2 = candidate.charCodeAt(candidateSpan.start + _i); - if (_ch1 !== _ch2) { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (ch1 !== ch2) { return false; } } @@ -24087,7 +25576,7 @@ var ts; return result1.kind - result2.kind; } function compareCamelCase(result1, result2) { - if (result1.kind === 3 && result2.kind === 3) { + if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { return result2.camelCaseWeight - result1.camelCaseWeight; } return 0; @@ -24299,6 +25788,7 @@ var ts; return transition; } })(ts || (ts = {})); +/// var ts; (function (ts) { var SignatureHelp; @@ -24329,7 +25819,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 155 || node.parent.kind === 156) { + if (node.parent.kind === 157 || node.parent.kind === 158) { var callExpression = node.parent; if (node.kind === 24 || node.kind === 16) { @@ -24346,43 +25836,43 @@ var ts; } var listItemInfo = ts.findListItemInfo(node); if (listItemInfo) { - var _list = listItemInfo.list; - var _isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === _list.pos; - var argumentIndex = getArgumentIndex(_list, node); - var argumentCount = getArgumentCount(_list); + var list = listItemInfo.list; + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + var argumentIndex = getArgumentIndex(list, node); + var argumentCount = getArgumentCount(list); ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); return { - kind: _isTypeArgList ? 0 : 1, + kind: isTypeArgList ? 0 : 1, invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(_list), + argumentsSpan: getApplicableSpanForArguments(list), argumentIndex: argumentIndex, argumentCount: argumentCount }; } } - else if (node.kind === 10 && node.parent.kind === 157) { + else if (node.kind === 10 && node.parent.kind === 159) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 157) { + else if (node.kind === 11 && node.parent.parent.kind === 159) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 169); - var _argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; - return getArgumentListInfoForTemplate(tagExpression, _argumentIndex); + ts.Debug.assert(templateExpression.kind === 171); + var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 173 && node.parent.parent.parent.kind === 157) { + else if (node.parent.kind === 175 && node.parent.parent.parent.kind === 159) { var templateSpan = node.parent; - var _templateExpression = templateSpan.parent; - var _tagExpression = _templateExpression.parent; - ts.Debug.assert(_templateExpression.kind === 169); + var templateExpression = templateSpan.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 171); if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } - var spanIndex = _templateExpression.templateSpans.indexOf(templateSpan); - var _argumentIndex_1 = getArgumentIndexForTemplatePiece(spanIndex, node); - return getArgumentListInfoForTemplate(_tagExpression, _argumentIndex_1); + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } return undefined; } @@ -24440,7 +25930,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 169) { + if (template.kind === 171) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -24449,16 +25939,16 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 221; n = n.parent) { + for (var n = node; n.kind !== 224; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } if (n.pos < n.parent.pos || n.end > n.parent.end) { ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); } - var _argumentInfo = getImmediatelyContainingArgumentInfo(n); - if (_argumentInfo) { - return _argumentInfo; + var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); + if (argumentInfo_1) { + return argumentInfo_1; } } return undefined; @@ -24621,6 +26111,129 @@ var ts; return start < end; } ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + ts.positionBelongsToNode = positionBelongsToNode; + function isCompletedNode(n, sourceFile) { + if (ts.nodeIsMissing(n)) { + return false; + } + switch (n.kind) { + case 198: + case 199: + case 201: + case 154: + case 150: + case 145: + case 176: + case 203: + case 204: + return nodeEndsWith(n, 15, sourceFile); + case 220: + return isCompletedNode(n.block, sourceFile); + case 158: + if (!n.arguments) { + return true; + } + case 157: + case 161: + case 149: + return nodeEndsWith(n, 17, sourceFile); + case 142: + case 143: + return isCompletedNode(n.type, sourceFile); + case 135: + case 136: + case 137: + case 197: + case 162: + case 134: + case 133: + case 139: + case 138: + case 163: + if (n.body) { + return isCompletedNode(n.body, sourceFile); + } + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 17, sourceFile); + case 202: + return n.body && isCompletedNode(n.body, sourceFile); + case 180: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); + } + return isCompletedNode(n.thenStatement, sourceFile); + case 179: + return isCompletedNode(n.expression, sourceFile); + case 153: + case 151: + case 156: + case 127: + case 147: + return nodeEndsWith(n, 19, sourceFile); + case 140: + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 19, sourceFile); + case 217: + case 218: + return false; + case 183: + case 184: + case 185: + case 182: + return isCompletedNode(n.statement, sourceFile); + case 181: + var hasWhileKeyword = findChildOfKind(n, 100, sourceFile); + if (hasWhileKeyword) { + return nodeEndsWith(n, 17, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + case 144: + return isCompletedNode(n.exprName, sourceFile); + case 165: + case 164: + case 166: + case 172: + case 173: + var unaryWordExpression = n; + return isCompletedNode(unaryWordExpression.expression, sourceFile); + case 159: + return isCompletedNode(n.template, sourceFile); + case 171: + var lastSpan = ts.lastOrUndefined(n.templateSpans); + return isCompletedNode(lastSpan, sourceFile); + case 175: + return ts.nodeIsPresent(n.literal); + case 167: + return isCompletedNode(n.operand, sourceFile); + case 169: + return isCompletedNode(n.right, sourceFile); + case 170: + return isCompletedNode(n.whenFalse, sourceFile); + default: + return true; + } + } + ts.isCompletedNode = isCompletedNode; + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = children[children.length - 1]; + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 22 && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } function findListItemInfo(node) { var list = findContainingList(node); if (!list) { @@ -24634,13 +26247,17 @@ var ts; }; } ts.findListItemInfo = findListItemInfo; + function hasChildOfKind(n, kind, sourceFile) { + return !!findChildOfKind(n, kind, sourceFile); + } + ts.hasChildOfKind = hasChildOfKind; function findChildOfKind(n, kind, sourceFile) { return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); } ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 222 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 225 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -24746,10 +26363,10 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 221); + ts.Debug.assert(startNode !== undefined || n.kind === 224); if (children.length) { - var _candidate = findRightmostChildNodeWithTokens(children, children.length); - return _candidate && findRightmostToken(_candidate); + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); } } function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { @@ -24783,22 +26400,23 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 139 || node.kind === 155) { + if (node.kind === 141 || node.kind === 157) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 196 || node.kind === 197) { + if (ts.isFunctionLike(node) || node.kind === 198 || node.kind === 199) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 124; + return n.kind >= 0 && n.kind <= 125; } ts.isToken = isToken; function isWord(kind) { - return kind === 64 || ts.isKeyword(kind); + return kind === 65 || ts.isKeyword(kind); } + ts.isWord = isWord; function isPropertyName(kind) { return kind === 8 || kind === 7 || isWord(kind); } @@ -24807,7 +26425,7 @@ var ts; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 <= kind && kind <= 63; + return 14 <= kind && kind <= 64; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -24815,6 +26433,16 @@ var ts; && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; + function isAccessibilityModifier(kind) { + switch (kind) { + case 109: + case 107: + case 108: + return true; + } + return false; + } + ts.isAccessibilityModifier = isAccessibilityModifier; function compareDataObjects(dst, src) { for (var e in dst) { if (typeof dst[e] === "object") { @@ -24835,7 +26463,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 128; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 129; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -24846,12 +26474,12 @@ var ts; resetWriter(); return { displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, 5); }, - writeOperator: function (text) { return writeKind(text, 12); }, - writePunctuation: function (text) { return writeKind(text, 15); }, - writeSpace: function (text) { return writeKind(text, 16); }, - writeStringLiteral: function (text) { return writeKind(text, 8); }, - writeParameter: function (text) { return writeKind(text, 13); }, + writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, + writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, + writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, + writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, + writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, writeSymbol: writeSymbol, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -24863,7 +26491,7 @@ var ts; if (lineStart) { var indentString = ts.getIndentString(indent); if (indentString) { - displayParts.push(displayPart(indentString, 16)); + displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); } lineStart = false; } @@ -24891,48 +26519,48 @@ var ts; function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3) { - return isFirstDeclarationOfSymbolParameter(symbol) ? 13 : 9; + return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } else if (flags & 4) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 32768) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 65536) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 8) { - return 19; + return ts.SymbolDisplayPartKind.enumMemberName; } else if (flags & 16) { - return 20; + return ts.SymbolDisplayPartKind.functionName; } else if (flags & 32) { - return 1; + return ts.SymbolDisplayPartKind.className; } else if (flags & 64) { - return 4; + return ts.SymbolDisplayPartKind.interfaceName; } else if (flags & 384) { - return 2; + return ts.SymbolDisplayPartKind.enumName; } else if (flags & 1536) { - return 11; + return ts.SymbolDisplayPartKind.moduleName; } else if (flags & 8192) { - return 10; + return ts.SymbolDisplayPartKind.methodName; } else if (flags & 262144) { - return 18; + return ts.SymbolDisplayPartKind.typeParameterName; } else if (flags & 524288) { - return 0; + return ts.SymbolDisplayPartKind.aliasName; } else if (flags & 8388608) { - return 0; + return ts.SymbolDisplayPartKind.aliasName; } - return 17; + return ts.SymbolDisplayPartKind.text; } } ts.symbolPart = symbolPart; @@ -24944,27 +26572,34 @@ var ts; } ts.displayPart = displayPart; function spacePart() { - return displayPart(" ", 16); + return displayPart(" ", ts.SymbolDisplayPartKind.space); } ts.spacePart = spacePart; function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), 5); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); } ts.keywordPart = keywordPart; function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), 15); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); } ts.punctuationPart = punctuationPart; function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), 12); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); } ts.operatorPart = operatorPart; + function textOrKeywordPart(text) { + var kind = ts.stringToToken(text); + return kind === undefined + ? textPart(text) + : keywordPart(kind); + } + ts.textOrKeywordPart = textOrKeywordPart; function textPart(text) { - return displayPart(text, 17); + return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; function lineBreakPart() { - return displayPart("\n", 6); + return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } ts.lineBreakPart = lineBreakPart; function mapToDisplayParts(writeDisplayParts) { @@ -24993,6 +26628,8 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { var formatting; @@ -25044,21 +26681,21 @@ var ts; var t; var pos = scanner.getStartPos(); while (pos < endPos) { - var _t = scanner.getToken(); - if (!ts.isTrivia(_t)) { + var t_2 = scanner.getToken(); + if (!ts.isTrivia(t_2)) { break; } scanner.scan(); - var _item = { + var item_4 = { pos: pos, end: scanner.getStartPos(), - kind: _t + kind: t_2 }; pos = scanner.getStartPos(); if (!leadingTrivia) { leadingTrivia = []; } - leadingTrivia.push(_item); + leadingTrivia.push(item_4); } savedPos = scanner.getStartPos(); } @@ -25066,8 +26703,8 @@ var ts; if (node) { switch (node.kind) { case 27: - case 59: case 60: + case 61: case 42: case 41: return true; @@ -25083,7 +26720,7 @@ var ts; container.kind === 13; } function startsWithSlashToken(t) { - return t === 36 || t === 56; + return t === 36 || t === 57; } function readTokenInfo(n) { if (!isOnToken()) { @@ -25162,8 +26799,8 @@ var ts; } function isOnToken() { var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var _startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); - return _startPos < endPos && current !== 1 && !ts.isTrivia(current); + var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + return startPos < endPos && current !== 1 && !ts.isTrivia(current); } function fixTokenKind(tokenInfo, container) { if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { @@ -25175,6 +26812,21 @@ var ts; formatting.getFormattingScanner = getFormattingScanner; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25253,6 +26905,21 @@ var ts; formatting.FormattingContext = FormattingContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25267,6 +26934,21 @@ var ts; var FormattingRequestKind = formatting.FormattingRequestKind; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25288,6 +26970,21 @@ var ts; formatting.Rule = Rule; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25301,6 +26998,21 @@ var ts; var RuleAction = formatting.RuleAction; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25331,6 +27043,21 @@ var ts; formatting.RuleDescriptor = RuleDescriptor; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25342,6 +27069,21 @@ var ts; var RuleFlags = formatting.RuleFlags; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25369,6 +27111,21 @@ var ts; formatting.RuleOperation = RuleOperation; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25402,12 +27159,30 @@ var ts; formatting.RuleOperationContext = RuleOperationContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; (function (formatting) { var Rules = (function () { function Rules() { + /// + /// Common Rules + /// this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -25418,8 +27193,8 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(50, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 75), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 99), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 76), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 100), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.FromTokens([17, 19, 23, 22])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -25429,9 +27204,9 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([64, 3]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([65, 3]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 74, 95, 80, 75]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 75, 96, 81, 76]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); @@ -25450,25 +27225,25 @@ var ts; this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(34, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([97, 93, 87, 73, 89, 96]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104, 69]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98, 94, 88, 74, 90, 97]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105, 70]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(82, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(98, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(89, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 74, 75, 66]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([95, 80]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([115, 119]), 64), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(99, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 75, 76, 67]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96, 81]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 120]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(113, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 117]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([68, 114, 76, 77, 78, 115, 102, 84, 103, 116, 106, 108, 119, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([78, 102])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117, 118]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 103, 85, 104, 117, 107, 109, 120, 110]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 103])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 64), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(50, formatting.Shared.TokenRange.FromTokens([17, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); @@ -25541,42 +27316,42 @@ var ts; this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(82, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(82, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var _name in o) { - if (o[_name] === rule) { - return _name; + for (var name_19 in o) { + if (o[name_19] === rule) { + return name_19; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 183; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 167: - case 168: + case 169: + case 170: return true; - case 203: - case 193: - case 128: - case 220: - case 130: + case 205: + case 195: case 129: - return context.currentTokenSpan.kind === 52 || context.nextTokenSpan.kind === 52; - case 182: - return context.currentTokenSpan.kind === 85 || context.nextTokenSpan.kind === 85; - case 183: - return context.currentTokenSpan.kind === 124 || context.nextTokenSpan.kind === 124; - case 150: - return context.currentTokenSpan.kind === 52 || context.nextTokenSpan.kind === 52; + case 223: + case 132: + case 131: + return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; + case 184: + return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; + case 185: + return context.currentTokenSpan.kind === 125 || context.nextTokenSpan.kind === 125; + case 152: + return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; } return false; }; @@ -25584,9 +27359,25 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 168; + return context.contextNode.kind === 170; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { + //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. + //// + //// Ex: + //// if (1) { .... + //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context + //// + //// Ex: + //// if (1) + //// { ... } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. + //// + //// Ex: + //// if (1) + //// { ... + //// } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { @@ -25609,26 +27400,26 @@ var ts; return true; } switch (node.kind) { - case 174: - case 202: - case 152: - case 201: + case 176: + case 204: + case 154: + case 203: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 195: - case 132: - case 131: - case 134: - case 135: - case 136: - case 160: - case 133: - case 161: case 197: + case 134: + case 133: + case 136: + case 137: + case 138: + case 162: + case 135: + case 163: + case 199: return true; } return false; @@ -25638,53 +27429,53 @@ var ts; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 196: - case 197: + case 198: case 199: - case 143: - case 200: + case 201: + case 145: + case 202: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 196: - case 200: - case 199: - case 174: - case 217: + case 198: + case 202: case 201: - case 188: + case 176: + case 220: + case 203: + case 190: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 178: - case 188: - case 181: - case 182: - case 183: case 180: - case 191: - case 179: - case 187: - case 217: + case 190: + case 183: + case 184: + case 185: + case 182: + case 193: + case 181: + case 189: + case 220: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 152; + return context.contextNode.kind === 154; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 155; + return context.contextNode.kind === 157; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 156; + return context.contextNode.kind === 158; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -25696,35 +27487,35 @@ var ts; return context.TokensAreOnSameLine(); }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 194 && + return context.currentTokenParent.kind === 196 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind != 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 200; + return context.contextNode.kind === 202; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 143; + return context.contextNode.kind === 145; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 && token.kind !== 25) { return false; } switch (parent.kind) { - case 139: - case 196: + case 141: + case 198: + case 199: case 197: - case 195: - case 160: - case 161: - case 132: - case 131: - case 136: - case 137: - case 155: - case 156: + case 162: + case 163: + case 134: + case 133: + case 138: + case 139: + case 157: + case 158: return true; default: return false; @@ -25735,13 +27526,28 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 98 && context.currentTokenParent.kind === 164; + return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 166; }; return Rules; })(); formatting.Rules = Rules; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25757,7 +27563,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 124 + 1; + this.mapRowLength = 125 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -25852,7 +27658,7 @@ var ts; var position; if (rule.Operation.Action == 1) { position = specificTokens ? - 0 : + RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; } else if (!rule.Operation.Context.IsAny()) { @@ -25878,6 +27684,21 @@ var ts; formatting.RulesBucket = RulesBucket; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25933,7 +27754,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 124; token++) { + for (var token = 0; token <= 125; token++) { result.push(token); } return result; @@ -25975,23 +27796,64 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(65, 124); - TokenRange.BinaryOperators = TokenRange.FromRange(24, 63); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([85, 86, 124]); + TokenRange.Keywords = TokenRange.FromRange(66, 125); + TokenRange.BinaryOperators = TokenRange.FromRange(24, 64); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38, 39, 47, 46]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 64, 16, 18, 14, 92, 87]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([64, 16, 92, 87]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([64, 17, 19, 87]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([64, 16, 92, 87]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([64, 17, 19, 87]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 65, 16, 18, 14, 93, 88]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([64, 118, 120, 112, 121, 98, 111]); + TokenRange.TypeNames = TokenRange.FromTokens([65, 119, 121, 113, 122, 99, 112]); return TokenRange; })(); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -26077,6 +27939,10 @@ var ts; formatting.RulesProvider = RulesProvider; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// +/// +/// +/// var ts; (function (ts) { var formatting; @@ -26122,13 +27988,13 @@ var ts; } formatting.formatSelection = formatSelection; function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { - var _parent = findOutermostParent(position, expectedLastToken, sourceFile); - if (!_parent) { + var parent = findOutermostParent(position, expectedLastToken, sourceFile); + if (!parent) { return []; } var span = { - pos: ts.getLineStartPositionForPosition(_parent.getStart(sourceFile), sourceFile), - end: _parent.end + pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), + end: parent.end }; return formatSpan(span, sourceFile, options, rulesProvider, requestKind); } @@ -26150,17 +28016,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 196: - case 197: + case 198: + case 199: return ts.rangeContainsRange(parent.members, node); - case 200: + case 202: var body = parent.body; - return body && body.kind === 174 && ts.rangeContainsRange(body.statements, node); - case 221: - case 174: - case 201: + return body && body.kind === 176 && ts.rangeContainsRange(body.statements, node); + case 224: + case 176: + case 203: return ts.rangeContainsRange(parent.statements, node); - case 217: + case 220: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -26265,10 +28131,10 @@ var ts; } } else { - var _startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; + var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); - if (_startLine !== parentStartLine || startPos === column) { + if (startLine !== parentStartLine || startPos === column) { return column; } } @@ -26279,9 +28145,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 221 || - parent.kind === 214 || - parent.kind === 215) { + parent.kind === 224 || + parent.kind === 217 || + parent.kind === 218) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -26307,6 +28173,26 @@ var ts; delta: delta }; } + function getFirstNonDecoratorTokenOfNode(node) { + if (node.modifiers && node.modifiers.length) { + return node.modifiers[0].kind; + } + switch (node.kind) { + case 198: return 69; + case 199: return 104; + case 197: return 83; + case 201: return 201; + case 136: return 116; + case 137: return 120; + case 134: + if (node.asteriskToken) { + return 35; + } + case 132: + case 129: + return node.name.kind; + } + } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { return { getIndentationForComment: function (kind) { @@ -26318,13 +28204,19 @@ var ts; return indentation; }, getIndentationForToken: function (line, kind) { + if (nodeStartLine !== line && node.decorators) { + if (kind === getFirstNonDecoratorTokenOfNode(node)) { + return indentation; + } + } switch (kind) { case 14: case 15: case 18: case 19: - case 75: - case 99: + case 76: + case 100: + case 52: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -26385,19 +28277,19 @@ var ts; return inheritedIndentation; } while (formattingScanner.isOnToken()) { - var _tokenInfo = formattingScanner.readTokenInfo(node); - if (_tokenInfo.token.end > childStartPos) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(_tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; } if (ts.isToken(child)) { - var _tokenInfo_1 = formattingScanner.readTokenInfo(child); - ts.Debug.assert(_tokenInfo_1.token.end === child.end); - consumeTokenAndAdvanceScanner(_tokenInfo_1, node, parentDynamicIndentation); + var tokenInfo = formattingScanner.readTokenInfo(child); + ts.Debug.assert(tokenInfo.token.end === child.end); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } var childIndentation = computeIndentation(child, childStart.line, childIndentationAmount, node, parentDynamicIndentation, parentStartLine); @@ -26409,34 +28301,34 @@ var ts; var listStartToken = getOpenTokenForList(parent, nodes); var listEndToken = getCloseTokenForOpenToken(listStartToken); var listDynamicIndentation = parentDynamicIndentation; - var _startLine = parentStartLine; + var startLine = parentStartLine; if (listStartToken !== 0) { while (formattingScanner.isOnToken()) { - var _tokenInfo = formattingScanner.readTokenInfo(parent); - if (_tokenInfo.token.end > nodes.pos) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.end > nodes.pos) { break; } - else if (_tokenInfo.token.kind === listStartToken) { - _startLine = sourceFile.getLineAndCharacterOfPosition(_tokenInfo.token.pos).line; - var _indentation = computeIndentation(_tokenInfo.token, _startLine, -1, parent, parentDynamicIndentation, _startLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, _indentation.indentation, _indentation.delta); - consumeTokenAndAdvanceScanner(_tokenInfo, parent, listDynamicIndentation); + else if (tokenInfo.token.kind === listStartToken) { + startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, startLine); + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } else { - consumeTokenAndAdvanceScanner(_tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); } } } var inheritedIndentation = -1; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, _startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, true); } if (listEndToken !== 0) { if (formattingScanner.isOnToken()) { - var _tokenInfo_1 = formattingScanner.readTokenInfo(parent); - if (_tokenInfo_1.token.kind === listEndToken && ts.rangeContainsRange(parent, _tokenInfo_1.token)) { - consumeTokenAndAdvanceScanner(_tokenInfo_1, parent, listDynamicIndentation); + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } } } @@ -26487,8 +28379,8 @@ var ts; break; case 2: if (indentNextTokenOrTrivia) { - var _commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, _commentIndentation, false); + var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); + insertIndentation(triviaItem.pos, commentIndentation_1, false); indentNextTokenOrTrivia = false; } break; @@ -26580,10 +28472,10 @@ var ts; } } function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { - var _startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; + var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; var parts; - if (_startLine === endLine) { + if (startLine === endLine) { if (!firstLineIsIndented) { insertIndentation(commentRange.pos, indentation, false); } @@ -26592,14 +28484,14 @@ var ts; else { parts = []; var startPos = commentRange.pos; - for (var line = _startLine; line < endLine; ++line) { + for (var line = startLine; line < endLine; ++line) { var endOfLine = ts.getEndLinePosition(line, sourceFile); parts.push({ pos: startPos, end: endOfLine }); startPos = ts.getStartPositionOfLine(line + 1, sourceFile); } parts.push({ pos: startPos, end: commentRange.end }); } - var startLinePos = ts.getStartPositionOfLine(_startLine, sourceFile); + var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); if (indentation === nonWhitespaceColumnInFirstPart.column) { return; @@ -26607,21 +28499,21 @@ var ts; var startIndex = 0; if (firstLineIsIndented) { startIndex = 1; - _startLine++; + startLine++; } - var _delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; ++i, ++_startLine) { - var _startLinePos = ts.getStartPositionOfLine(_startLine, sourceFile); + var delta = indentation - nonWhitespaceColumnInFirstPart.column; + for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { + var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - var newIndentation = nonWhitespaceCharacterAndColumn.column + _delta; + var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; if (newIndentation > 0) { var indentationString = getIndentationString(newIndentation, options); - recordReplace(_startLinePos, nonWhitespaceCharacterAndColumn.character, indentationString); + recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); } else { - recordDelete(_startLinePos, nonWhitespaceCharacterAndColumn.character); + recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); } } } @@ -26688,20 +28580,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 174: - case 201: + case 176: + case 203: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 135: + case 197: + case 162: + case 134: case 133: - case 195: - case 160: - case 132: - case 131: - case 161: + case 163: if (node.typeParameters === list) { return 24; } @@ -26709,8 +28601,8 @@ var ts; return 16; } break; - case 155: - case 156: + case 157: + case 158: if (node.typeArguments === list) { return 24; } @@ -26718,7 +28610,7 @@ var ts; return 16; } break; - case 139: + case 141: if (node.typeArguments === list) { return 24; } @@ -26734,9 +28626,15 @@ var ts; } return 0; } + var internedSizes; var internedTabsIndentation; var internedSpacesIndentation; function getIndentationString(indentation, options) { + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + if (resetInternedStrings) { + internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; + } if (!options.ConvertTabsToSpaces) { var tabs = Math.floor(indentation / options.TabSize); var spaces = indentation - tabs * options.TabSize; @@ -26779,6 +28677,7 @@ var ts; formatting.getIndentationString = getIndentationString; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { var formatting; @@ -26807,7 +28706,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 167) { + if (precedingToken.kind === 23 && precedingToken.parent.kind !== 169) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -26818,7 +28717,7 @@ var ts; var currentStart; var indentationDelta; while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0)) { + if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { indentationDelta = 0; @@ -26828,9 +28727,9 @@ var ts; } break; } - var _actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (_actualIndentation !== -1) { - return _actualIndentation; + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; } previous = current; current = current.parent; @@ -26847,9 +28746,9 @@ var ts; } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var _parent = current.parent; + var parent = current.parent; var parentStart; - while (_parent) { + while (parent) { var useActualIndentation = true; if (ignoreActualIndentationRange) { var start = current.getStart(sourceFile); @@ -26861,21 +28760,21 @@ var ts; return actualIndentation + indentationDelta; } } - parentStart = getParentStart(_parent, current, sourceFile); + parentStart = getParentStart(parent, current, sourceFile); var parentAndChildShareLine = parentStart.line === currentStart.line || - childStartsOnTheSameLineWithElseInIfStatement(_parent, current, currentStart.line, sourceFile); + childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { - var _actualIndentation = getActualIndentationForNode(current, _parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (_actualIndentation !== -1) { - return _actualIndentation + indentationDelta; + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; } } - if (shouldIndentChildNode(_parent.kind, current.kind) && !parentAndChildShareLine) { + if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { indentationDelta += options.IndentSize; } - current = _parent; + current = parent; currentStart = parentStart; - _parent = current.parent; + parent = current.parent; } return indentationDelta; } @@ -26897,7 +28796,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 221 || !parentAndChildShareLine); + (parent.kind === 224 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -26920,12 +28819,9 @@ var ts; function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 178 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 75, sourceFile); + if (parent.kind === 180 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 76, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -26936,23 +28832,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 139: + case 141: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 152: + case 154: return node.parent.properties; - case 151: + case 153: return node.parent.elements; - case 195: - case 160: - case 161: - case 132: - case 131: - case 136: - case 137: { + case 197: + case 162: + case 163: + case 134: + case 133: + case 138: + case 139: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -26963,15 +28859,15 @@ var ts; } break; } - case 156: - case 155: { - var _start = node.getStart(sourceFile); + case 158: + case 157: { + var start = node.getStart(sourceFile); if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, _start, node.getEnd())) { + ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { return node.parent.typeArguments; } if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, _start, node.getEnd())) { + ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { return node.parent.arguments; } break; @@ -27033,25 +28929,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 196: - case 197: + case 198: case 199: - case 151: - case 174: case 201: - case 152: - case 143: - case 202: - case 215: - case 214: - case 159: - case 155: - case 156: - case 175: - case 193: - case 209: - case 186: - case 168: + case 153: + case 176: + case 203: + case 154: + case 145: + case 147: + case 204: + case 218: + case 217: + case 161: + case 157: + case 158: + case 177: + case 195: + case 211: + case 188: + case 170: + case 151: + case 150: return true; } return false; @@ -27061,106 +28960,46 @@ var ts; return true; } switch (parent) { - case 179: - case 180: - case 182: - case 183: case 181: - case 178: - case 195: - case 160: - case 132: - case 131: - case 161: - case 133: + case 182: + case 184: + case 185: + case 183: + case 180: + case 197: + case 162: case 134: + case 133: + case 138: + case 163: case 135: - return child !== 174; + case 136: + case 137: + return child !== 176; default: return false; } } SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = children[children.length - 1]; - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === 22 && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - function isCompletedNode(n, sourceFile) { - if (n.getFullWidth() === 0) { - return false; - } - switch (n.kind) { - case 196: - case 197: - case 199: - case 152: - case 174: - case 201: - case 202: - return nodeEndsWith(n, 15, sourceFile); - case 217: - return isCompletedNode(n.block, sourceFile); - case 159: - case 136: - case 155: - case 137: - return nodeEndsWith(n, 17, sourceFile); - case 195: - case 160: - case 132: - case 131: - case 161: - return !n.body || isCompletedNode(n.body, sourceFile); - case 200: - return n.body && isCompletedNode(n.body, sourceFile); - case 178: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); - } - return isCompletedNode(n.thenStatement, sourceFile); - case 177: - return isCompletedNode(n.expression, sourceFile); - case 151: - return nodeEndsWith(n, 19, sourceFile); - case 214: - case 215: - return false; - case 181: - return isCompletedNode(n.statement, sourceFile); - case 182: - return isCompletedNode(n.statement, sourceFile); - case 183: - return isCompletedNode(n.statement, sourceFile); - case 180: - return isCompletedNode(n.statement, sourceFile); - case 179: - var hasWhileKeyword = ts.findChildOfKind(n, 99, sourceFile); - if (hasWhileKeyword) { - return nodeEndsWith(n, 17, sourceFile); - } - return isCompletedNode(n.statement, sourceFile); - default: - return true; - } - } })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// var __extends = this.__extends || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }; +/// +/// +/// +/// +/// +/// +/// +/// +/// var ts; (function (ts) { ts.servicesVersion = "0.4"; @@ -27238,7 +29077,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(222, nodes.pos, nodes.end, 1024, this); + var list = createNode(225, nodes.pos, nodes.end, 1024, this); list._children = []; var pos = nodes.pos; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { @@ -27257,7 +29096,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 125) { + if (this.kind >= 126) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -27302,7 +29141,7 @@ var ts; var children = this.getChildren(); for (var _i = 0, _n = children.length; _i < _n; _i++) { var child = children[_i]; - if (child.kind < 125) { + if (child.kind < 126) { return child; } return child.getFirstToken(sourceFile); @@ -27312,7 +29151,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 125) { + if (child.kind < 126) { return child; } return child.getLastToken(sourceFile); @@ -27358,7 +29197,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 128) { + if (canUseParsedParamTagComments && declaration.kind === 129) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -27366,13 +29205,13 @@ var ts; } }); } - if (declaration.kind === 200 && declaration.body.kind === 200) { + if (declaration.kind === 202 && declaration.body.kind === 202) { return; } - while (declaration.kind === 200 && declaration.parent.kind === 200) { + while (declaration.kind === 202 && declaration.parent.kind === 202) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 193 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 195 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -27417,13 +29256,14 @@ var ts; return isName(pos, end, sourceFile, paramTag); } function pushDocCommentLineText(docComments, text, blankLineCount) { - while (blankLineCount--) + while (blankLineCount--) { docComments.push(ts.textPart("")); + } docComments.push(ts.textPart(text)); } function getCleanedJsDocComment(pos, end, sourceFile) { var spacesToRemoveAfterAsterisk; - var _docComments = []; + var docComments = []; var blankLineCount = 0; var isInParamTag = false; while (pos < end) { @@ -27458,14 +29298,14 @@ var ts; } pos = consumeLineBreaks(pos, end, sourceFile); if (docCommentTextOfLine) { - pushDocCommentLineText(_docComments, docCommentTextOfLine, blankLineCount); + pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); blankLineCount = 0; } - else if (!isInParamTag && _docComments.length) { + else if (!isInParamTag && docComments.length) { blankLineCount++; } } - return _docComments; + return docComments; } function getCleanedParamJsDocComment(pos, end, sourceFile) { var paramHelpStringMargin; @@ -27566,8 +29406,8 @@ var ts; } var consumedSpaces = pos - startOfLinePos; if (consumedSpaces < paramHelpStringMargin) { - var _ch = sourceFile.text.charCodeAt(pos); - if (_ch === 42) { + var ch = sourceFile.text.charCodeAt(pos); + if (ch === 42) { pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); } } @@ -27656,9 +29496,9 @@ var ts; var namedDeclarations = []; ts.forEachChild(sourceFile, function visit(node) { switch (node.kind) { - case 195: - case 132: - case 131: + case 197: + case 134: + case 133: var functionDeclaration = node; if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) { var lastDeclaration = namedDeclarations.length > 0 ? @@ -27675,64 +29515,64 @@ var ts; ts.forEachChild(node, visit); } break; - case 196: - case 197: case 198: case 199: case 200: - case 203: - case 212: - case 208: - case 203: + case 201: + case 202: case 205: - case 206: - case 134: - case 135: - case 143: + case 214: + case 210: + case 205: + case 207: + case 208: + case 136: + case 137: + case 145: if (node.name) { namedDeclarations.push(node); } - case 133: - case 175: - case 194: - case 148: - case 149: - case 201: + case 135: + case 177: + case 196: + case 150: + case 151: + case 203: ts.forEachChild(node, visit); break; - case 174: + case 176: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 128: + case 129: if (!(node.flags & 112)) { break; } - case 193: - case 150: + case 195: + case 152: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 220: - case 130: - case 129: + case 223: + case 132: + case 131: namedDeclarations.push(node); break; - case 210: + case 212: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 204: + case 206: var importClause = node.importClause; if (importClause) { if (importClause.name) { namedDeclarations.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { namedDeclarations.push(importClause.namedBindings); } else { @@ -27887,14 +29727,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 160) { + if (declaration.kind === 162) { return true; } - if (declaration.kind !== 193 && declaration.kind !== 195) { + if (declaration.kind !== 195 && declaration.kind !== 197) { return false; } - for (var _parent = declaration.parent; !ts.isFunctionBlock(_parent); _parent = _parent.parent) { - if (_parent.kind === 221 || _parent.kind === 201) { + for (var parent_7 = declaration.parent; !ts.isFunctionBlock(parent_7); parent_7 = parent_7.parent) { + if (parent_7.kind === 224 || parent_7.kind === 203) { return false; } } @@ -27996,17 +29836,17 @@ var ts; if (!scriptSnapshot) { throw new Error("Could not find file: '" + fileName + "'."); } - var _version = this.host.getScriptVersion(fileName); + var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, _version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true); } - else if (this.currentFileVersion !== _version) { + else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); - sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, _version, editRange); + sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); } if (sourceFile) { - this.currentFileVersion = _version; + this.currentFileVersion = version; this.currentFileName = fileName; this.currentFileScriptSnapshot = scriptSnapshot; this.currentSourceFile = sourceFile; @@ -28152,25 +29992,25 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1) { - if (token === 84) { + if (token === 85) { token = scanner.scan(); if (token === 8) { recordModuleName(); continue; } else { - if (token === 64) { + if (token === 65) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); continue; } } - else if (token === 52) { + else if (token === 53) { token = scanner.scan(); - if (token === 117) { + if (token === 118) { token = scanner.scan(); if (token === 16) { token = scanner.scan(); @@ -28195,7 +30035,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -28205,11 +30045,11 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 101) { + if (token === 102) { token = scanner.scan(); - if (token === 64) { + if (token === 65) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -28220,7 +30060,7 @@ var ts; } } } - else if (token === 77) { + else if (token === 78) { token = scanner.scan(); if (token === 14) { token = scanner.scan(); @@ -28229,7 +30069,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -28239,7 +30079,7 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -28260,7 +30100,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 189 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 191 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -28268,17 +30108,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 64 && - (node.parent.kind === 185 || node.parent.kind === 184) && + return node.kind === 65 && + (node.parent.kind === 187 || node.parent.kind === 186) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 64 && - node.parent.kind === 189 && + return node.kind === 65 && + node.parent.kind === 191 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 189; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 191; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -28289,48 +30129,48 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 125 && node.parent.right === node; + return node.parent.kind === 126 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 153 && node.parent.name === node; + return node && node.parent && node.parent.kind === 155 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 155 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 157 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 156 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 158 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 200 && node.parent.name === node; + return node.parent.kind === 202 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 64 && + return node.kind === 65 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 64 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 218 || node.parent.kind === 219) && node.parent.name === node; + return (node.kind === 65 || node.kind === 8 || node.kind === 7) && + (node.parent.kind === 221 || node.parent.kind === 222) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 || node.kind === 7) { switch (node.parent.kind) { - case 130: - case 129: - case 218: - case 220: case 132: case 131: + case 221: + case 223: case 134: - case 135: - case 200: + case 133: + case 136: + case 137: + case 202: return node.parent.name === node; - case 154: + case 156: return node.parent.argumentExpression === node; } } @@ -28383,7 +30223,7 @@ var ts; BreakContinueSearchType[BreakContinueSearchType["All"] = 3] = "All"; })(BreakContinueSearchType || (BreakContinueSearchType = {})); var keywordCompletions = []; - for (var i = 65; i <= 124; i++) { + for (var i = 66; i <= 125; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -28397,17 +30237,17 @@ var ts; return undefined; } switch (node.kind) { - case 221: - case 132: - case 131: - case 195: - case 160: + case 224: case 134: - case 135: - case 196: + case 133: case 197: + case 162: + case 136: + case 137: + case 198: case 199: - case 200: + case 201: + case 202: return node; } } @@ -28415,38 +30255,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 200: return ScriptElementKind.moduleElement; - case 196: return ScriptElementKind.classElement; - case 197: return ScriptElementKind.interfaceElement; - case 198: return ScriptElementKind.typeElement; - case 199: return ScriptElementKind.enumElement; - case 193: + case 202: return ScriptElementKind.moduleElement; + case 198: return ScriptElementKind.classElement; + case 199: return ScriptElementKind.interfaceElement; + case 200: return ScriptElementKind.typeElement; + case 201: return ScriptElementKind.enumElement; + case 195: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 195: return ScriptElementKind.functionElement; - case 134: return ScriptElementKind.memberGetAccessorElement; - case 135: return ScriptElementKind.memberSetAccessorElement; + case 197: return ScriptElementKind.functionElement; + case 136: return ScriptElementKind.memberGetAccessorElement; + case 137: return ScriptElementKind.memberSetAccessorElement; + case 134: + case 133: + return ScriptElementKind.memberFunctionElement; case 132: case 131: - return ScriptElementKind.memberFunctionElement; - case 130: - case 129: return ScriptElementKind.memberVariableElement; - case 138: return ScriptElementKind.indexSignatureElement; - case 137: return ScriptElementKind.constructSignatureElement; - case 136: return ScriptElementKind.callSignatureElement; - case 133: return ScriptElementKind.constructorImplementationElement; - case 127: return ScriptElementKind.typeParameterElement; - case 220: return ScriptElementKind.variableElement; - case 128: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 203: - case 208: + case 140: return ScriptElementKind.indexSignatureElement; + case 139: return ScriptElementKind.constructSignatureElement; + case 138: return ScriptElementKind.callSignatureElement; + case 135: return ScriptElementKind.constructorImplementationElement; + case 128: return ScriptElementKind.typeParameterElement; + case 223: return ScriptElementKind.variableElement; + case 129: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 205: - case 212: - case 206: + case 210: + case 207: + case 214: + case 208: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -28460,7 +30300,6 @@ var ts; var typeInfoResolver; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - var activeCompletionSession; if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } @@ -28524,8 +30363,8 @@ var ts; return undefined; } if (!changesInCompilationSettingsAffectSyntax) { - var _oldSourceFile = program && program.getSourceFile(fileName); - if (_oldSourceFile) { + var oldSourceFile = program && program.getSourceFile(fileName); + if (oldSourceFile) { return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } } @@ -28542,9 +30381,9 @@ var ts; if (program.getSourceFiles().length !== rootFileNames.length) { return false; } - for (var _a = 0, _b = rootFileNames.length; _a < _b; _a++) { - var _fileName = rootFileNames[_a]; - if (!sourceFileUpToDate(program.getSourceFile(_fileName))) { + for (var _i = 0, _n = rootFileNames.length; _i < _n; _i++) { + var fileName = rootFileNames[_i]; + if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } } @@ -28579,35 +30418,42 @@ var ts; return semanticDiagnostics; } var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); - return semanticDiagnostics.concat(declarationDiagnostics); + return ts.concatenate(semanticDiagnostics, declarationDiagnostics); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); return program.getGlobalDiagnostics(); } - function getValidCompletionEntryDisplayName(symbol, target) { + function getCompletionEntryDisplayName(symbol, target, performCharacterChecks) { var displayName = symbol.getName(); - if (displayName && displayName.length > 0) { - var firstCharCode = displayName.charCodeAt(0); - if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { + if (!displayName) { + return undefined; + } + var firstCharCode = displayName.charCodeAt(0); + if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { + return undefined; + } + if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && + (firstCharCode === 39 || firstCharCode === 34)) { + displayName = displayName.substring(1, displayName.length - 1); + } + if (!displayName) { + return undefined; + } + if (performCharacterChecks) { + if (!ts.isIdentifierStart(displayName.charCodeAt(0), target)) { return undefined; } - if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && - (firstCharCode === 39 || firstCharCode === 34)) { - displayName = displayName.substring(1, displayName.length - 1); - } - var isValid = ts.isIdentifierStart(displayName.charCodeAt(0), target); - for (var _i = 1, n = displayName.length; isValid && _i < n; _i++) { - isValid = ts.isIdentifierPart(displayName.charCodeAt(_i), target); - } - if (isValid) { - return ts.unescapeIdentifier(displayName); + for (var i = 1, n = displayName.length; i < n; i++) { + if (!ts.isIdentifierPart(displayName.charCodeAt(i), target)) { + return undefined; + } } } - return undefined; + return ts.unescapeIdentifier(displayName); } function createCompletionEntry(symbol, typeChecker, location) { - var displayName = getValidCompletionEntryDisplayName(symbol, program.getCompilerOptions().target); + var displayName = getCompletionEntryDisplayName(symbol, program.getCompilerOptions().target, true); if (!displayName) { return undefined; } @@ -28617,63 +30463,53 @@ var ts; kindModifiers: getSymbolModifiers(symbol) }; } - function getCompletionsAtPosition(fileName, position) { - synchronizeHostData(); + function getCompletionData(fileName, position) { var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); - log("getCompletionsAtPosition: Get current token: " + (new Date().getTime() - start)); + log("getCompletionData: Get current token: " + (new Date().getTime() - start)); start = new Date().getTime(); var insideComment = isInsideComment(sourceFile, currentToken, position); - log("getCompletionsAtPosition: Is inside comment: " + (new Date().getTime() - start)); + log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { log("Returning an empty list because completion was inside a comment."); return undefined; } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); - log("getCompletionsAtPosition: Get previous token 1: " + (new Date().getTime() - start)); - if (previousToken && position <= previousToken.end && previousToken.kind === 64) { - var _start = new Date().getTime(); - previousToken = ts.findPrecedingToken(previousToken.pos, sourceFile); - log("getCompletionsAtPosition: Get previous token 2: " + (new Date().getTime() - _start)); + log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); + var contextToken = previousToken; + if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { + var start_1 = new Date().getTime(); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_1)); } - if (previousToken && isCompletionListBlocker(previousToken)) { + if (contextToken && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var node; - var isRightOfDot; - if (previousToken && previousToken.kind === 20 && previousToken.parent.kind === 153) { - node = previousToken.parent.expression; + var node = currentToken; + var isRightOfDot = false; + if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 155) { + node = contextToken.parent.expression; isRightOfDot = true; } - else if (previousToken && previousToken.kind === 20 && previousToken.parent.kind === 125) { - node = previousToken.parent.left; + else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 126) { + node = contextToken.parent.left; isRightOfDot = true; } - else { - node = currentToken; - isRightOfDot = false; - } - activeCompletionSession = { - fileName: fileName, - position: position, - entries: [], - symbols: {}, - typeChecker: typeInfoResolver - }; - log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart)); - var _location = ts.getTouchingPropertyName(sourceFile, position); + var location = ts.getTouchingPropertyName(sourceFile, position); + var target = program.getCompilerOptions().target; var semanticStart = new Date().getTime(); var isMemberCompletion; var isNewIdentifierLocation; + var symbols; if (isRightOfDot) { - var symbols = []; + symbols = []; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 64 || node.kind === 125 || node.kind === 153) { + if (node.kind === 65 || node.kind === 126 || node.kind === 155) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeInfoResolver.getAliasedSymbol(symbol); @@ -28694,10 +30530,9 @@ var ts; } }); } - getCompletionEntriesFromSymbols(symbols, activeCompletionSession); } else { - var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(previousToken); + var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); if (containingObjectLiteral) { isMemberCompletion = true; isNewIdentifierLocation = true; @@ -28707,65 +30542,54 @@ var ts; } var contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType); if (contextualTypeMembers && contextualTypeMembers.length > 0) { - var filteredMembers = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); - getCompletionEntriesFromSymbols(filteredMembers, activeCompletionSession); + symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(previousToken, 205)) { + else if (ts.getAncestor(contextToken, 207)) { isMemberCompletion = true; isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(previousToken)) { - var importDeclaration = ts.getAncestor(previousToken, 204); + if (showCompletionsInImportsClause(contextToken)) { + var importDeclaration = ts.getAncestor(contextToken, 206); ts.Debug.assert(importDeclaration !== undefined); var exports = typeInfoResolver.getExportsOfExternalModule(importDeclaration); - var filteredExports = filterModuleExports(exports, importDeclaration); - getCompletionEntriesFromSymbols(filteredExports, activeCompletionSession); + symbols = filterModuleExports(exports, importDeclaration); } } else { isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(previousToken); + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile); var symbolMeanings = 793056 | 107455 | 1536 | 8388608; - var _symbols = typeInfoResolver.getSymbolsInScope(node, symbolMeanings); - getCompletionEntriesFromSymbols(_symbols, activeCompletionSession); + symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings); } } - if (!isMemberCompletion) { - Array.prototype.push.apply(activeCompletionSession.entries, keywordCompletions); - } - log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart)); - return { - isMemberCompletion: isMemberCompletion, - isNewIdentifierLocation: isNewIdentifierLocation, - isBuilder: isNewIdentifierDefinitionLocation, - entries: activeCompletionSession.entries - }; - function getCompletionEntriesFromSymbols(symbols, session) { - var _start_1 = new Date().getTime(); - ts.forEach(symbols, function (symbol) { - var entry = createCompletionEntry(symbol, session.typeChecker, _location); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(session.symbols, id)) { - session.entries.push(entry); - session.symbols[id] = symbol; - } - } - }); - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - _start_1)); + log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location }; + function getScopeNode(initialToken, position, sourceFile) { + var scope = initialToken; + while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { + scope = scope.parent; + } + return scope; } function isCompletionListBlocker(previousToken) { - var _start_1 = new Date().getTime(); + var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || isIdentifierDefinitionLocation(previousToken) || isRightOfIllegalDot(previousToken); - log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - _start_1)); + log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } function showCompletionsInImportsClause(node) { if (node) { if (node.kind === 14 || node.kind === 23) { - return node.parent.kind === 207; + return node.parent.kind === 209; } } return false; @@ -28775,35 +30599,35 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 155 - || containingNodeKind === 133 - || containingNodeKind === 156 - || containingNodeKind === 151 - || containingNodeKind === 167; + return containingNodeKind === 157 + || containingNodeKind === 135 + || containingNodeKind === 158 + || containingNodeKind === 153 + || containingNodeKind === 169; case 16: - return containingNodeKind === 155 - || containingNodeKind === 133 - || containingNodeKind === 156 - || containingNodeKind === 159; + return containingNodeKind === 157 + || containingNodeKind === 135 + || containingNodeKind === 158 + || containingNodeKind === 161; case 18: - return containingNodeKind === 151; - case 116: + return containingNodeKind === 153; + case 117: return true; case 20: - return containingNodeKind === 200; + return containingNodeKind === 202; case 14: - return containingNodeKind === 196; - case 52: - return containingNodeKind === 193 - || containingNodeKind === 167; + return containingNodeKind === 198; + case 53: + return containingNodeKind === 195 + || containingNodeKind === 169; case 11: - return containingNodeKind === 169; + return containingNodeKind === 171; case 12: - return containingNodeKind === 173; - case 108: - case 106: + return containingNodeKind === 175; + case 109: case 107: - return containingNodeKind === 130; + case 108: + return containingNodeKind === 132; } switch (previousToken.getText()) { case "public": @@ -28818,9 +30642,9 @@ var ts; if (previousToken.kind === 8 || previousToken.kind === 9 || ts.isTemplateLiteralKind(previousToken.kind)) { - var _start_1 = previousToken.getStart(); + var start_2 = previousToken.getStart(); var end = previousToken.getEnd(); - if (_start_1 < position && position < end) { + if (start_2 < position && position < end) { return true; } else if (position === end) { @@ -28830,13 +30654,14 @@ var ts; return false; } function getContainingObjectLiteralApplicableForCompletion(previousToken) { + // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var _parent = previousToken.parent; + var parent_8 = previousToken.parent; switch (previousToken.kind) { case 14: case 23: - if (_parent && _parent.kind === 152) { - return _parent; + if (parent_8 && parent_8.kind === 154) { + return parent_8; } break; } @@ -28845,16 +30670,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 160: - case 161: - case 195: - case 132: - case 131: + case 162: + case 163: + case 197: case 134: - case 135: + case 133: case 136: case 137: case 138: + case 139: + case 140: return true; } return false; @@ -28864,58 +30689,58 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 193 || - containingNodeKind === 194 || - containingNodeKind === 175 || - containingNodeKind === 199 || - isFunction(containingNodeKind) || + return containingNodeKind === 195 || containingNodeKind === 196 || - containingNodeKind === 195 || + containingNodeKind === 177 || + containingNodeKind === 201 || + isFunction(containingNodeKind) || + containingNodeKind === 198 || containingNodeKind === 197 || - containingNodeKind === 149 || - containingNodeKind === 148; + containingNodeKind === 199 || + containingNodeKind === 151 || + containingNodeKind === 150; case 20: - return containingNodeKind === 149; + return containingNodeKind === 151; case 18: - return containingNodeKind === 149; + return containingNodeKind === 151; case 16: - return containingNodeKind === 217 || + return containingNodeKind === 220 || isFunction(containingNodeKind); case 14: - return containingNodeKind === 199 || - containingNodeKind === 197 || - containingNodeKind === 143 || - containingNodeKind === 148; + return containingNodeKind === 201 || + containingNodeKind === 199 || + containingNodeKind === 145 || + containingNodeKind === 150; case 22: - return containingNodeKind === 129 && - (previousToken.parent.parent.kind === 197 || - previousToken.parent.parent.kind === 143); + return containingNodeKind === 131 && + (previousToken.parent.parent.kind === 199 || + previousToken.parent.parent.kind === 145); case 24: - return containingNodeKind === 196 || - containingNodeKind === 195 || + return containingNodeKind === 198 || containingNodeKind === 197 || + containingNodeKind === 199 || isFunction(containingNodeKind); - case 109: - return containingNodeKind === 130; - case 21: - return containingNodeKind === 128 || - containingNodeKind === 133 || - (previousToken.parent.parent.kind === 149); - case 108: - case 106: - case 107: - return containingNodeKind === 128; - case 68: - case 76: - case 103: - case 82: - case 97: - case 115: - case 119: - case 84: - case 104: - case 69: case 110: + return containingNodeKind === 132; + case 21: + return containingNodeKind === 129 || + containingNodeKind === 135 || + (previousToken.parent.parent.kind === 151); + case 109: + case 107: + case 108: + return containingNodeKind === 129; + case 69: + case 77: + case 104: + case 83: + case 98: + case 116: + case 120: + case 85: + case 105: + case 70: + case 111: return true; } switch (previousToken.getText()) { @@ -28946,10 +30771,10 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 207) { + importDeclaration.importClause.namedBindings.kind === 209) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { - var _name = el.propertyName || el.name; - exisingImports[_name.text] = true; + var name = el.propertyName || el.name; + exisingImports[name.text] = true; }); } if (ts.isEmpty(exisingImports)) { @@ -28963,7 +30788,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 218 && m.kind !== 219) { + if (m.kind !== 221 && m.kind !== 222) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -28971,44 +30796,78 @@ var ts; } existingMemberNames[m.name.text] = true; }); - var _filteredMembers = []; + var filteredMembers = []; ts.forEach(contextualMemberSymbols, function (s) { if (!existingMemberNames[s.name]) { - _filteredMembers.push(s); + filteredMembers.push(s); } }); - return _filteredMembers; + return filteredMembers; + } + } + function getCompletionsAtPosition(fileName, position) { + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location; + if (!symbols || symbols.length === 0) { + return undefined; + } + var entries = getCompletionEntriesFromSymbols(symbols); + if (!isMemberCompletion) { + ts.addRange(entries, keywordCompletions); + } + return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + function getCompletionEntriesFromSymbols(symbols) { + var start = new Date().getTime(); + var entries = []; + var nameToSymbol = {}; + for (var _i = 0, _n = symbols.length; _i < _n; _i++) { + var symbol = symbols[_i]; + var entry = createCompletionEntry(symbol, typeInfoResolver, location); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!ts.lookUp(nameToSymbol, id)) { + entries.push(entry); + nameToSymbol[id] = symbol; + } + } + } + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); + return entries; } } function getCompletionEntryDetails(fileName, position, entryName) { - var sourceFile = getValidSourceFile(fileName); - var session = activeCompletionSession; - if (!session || session.fileName !== fileName || session.position !== position) { - return undefined; + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (completionData) { + var symbols = completionData.symbols, location_2 = completionData.location; + var target = program.getCompilerOptions().target; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayName(s, target, false) === entryName ? s : undefined; }); + if (symbol) { + var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, typeInfoResolver, location_2, 7); + return { + name: entryName, + kind: displayPartsDocumentationsAndSymbolKind.symbolKind, + kindModifiers: getSymbolModifiers(symbol), + displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, + documentation: displayPartsDocumentationsAndSymbolKind.documentation + }; + } } - var symbol = ts.lookUp(activeCompletionSession.symbols, ts.escapeIdentifier(entryName)); - if (symbol) { - var _location = ts.getTouchingPropertyName(sourceFile, position); - var completionEntry = createCompletionEntry(symbol, session.typeChecker, _location); - ts.Debug.assert(session.typeChecker.getTypeOfSymbolAtLocation(symbol, _location) !== undefined, "Could not find type for symbol"); - var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), _location, session.typeChecker, _location, 7); - return { - name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, - kindModifiers: completionEntry.kindModifiers, - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation - }; - } - else { + var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); + if (keywordCompletion) { return { name: entryName, kind: ScriptElementKind.keyword, kindModifiers: ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, 5)], + displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], documentation: undefined }; } + return undefined; } function getSymbolKind(symbol, typeResolver, location) { var flags = symbol.getFlags(); @@ -29122,14 +30981,14 @@ var ts; var signature; type = typeResolver.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 153) { + if (location.parent && location.parent.kind === 155) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 155 || location.kind === 156) { + if (location.kind === 157 || location.kind === 158) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -29141,7 +31000,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 156 || callExpression.expression.kind === 90; + var useConstructSignatures = callExpression.kind === 158 || callExpression.expression.kind === 91; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -29153,12 +31012,10 @@ var ts; } else if (symbolFlags & 8388608) { symbolKind = ScriptElementKind.alias; - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart(symbolKind)); - displayParts.push(ts.punctuationPart(17)); + pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -29176,7 +31033,7 @@ var ts; displayParts.push(ts.punctuationPart(51)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } if (!(type.flags & 32768)) { @@ -29191,64 +31048,64 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 113 && location.parent.kind === 133)) { + (location.kind === 114 && location.parent.kind === 135)) { var functionDeclaration = location.parent; - var _allSignatures = functionDeclaration.kind === 133 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 135 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeResolver.isImplementationOfOverload(functionDeclaration)) { signature = typeResolver.getSignatureFromDeclaration(functionDeclaration); } else { - signature = _allSignatures[0]; + signature = allSignatures[0]; } - if (functionDeclaration.kind === 133) { + if (functionDeclaration.kind === 135) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 136 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 138 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } - addSignatureDisplayParts(signature, _allSignatures); + addSignatureDisplayParts(signature, allSignatures); hasAddedSymbolInfo = true; } } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - displayParts.push(ts.keywordPart(68)); + displayParts.push(ts.keywordPart(69)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(103)); + displayParts.push(ts.keywordPart(104)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(122)); + displayParts.push(ts.keywordPart(123)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(69)); + displayParts.push(ts.keywordPart(70)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(76)); + displayParts.push(ts.keywordPart(77)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(116)); + displayParts.push(ts.keywordPart(117)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -29260,60 +31117,60 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(85)); + displayParts.push(ts.keywordPart(86)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 127).parent; - var _signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 137) { - displayParts.push(ts.keywordPart(87)); + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128).parent; + var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 139) { + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 136 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 138 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, _signature, sourceFile, 32)); + displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, sourceFile, 32)); } } if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 220) { + if (declaration.kind === 223) { var constantValue = typeResolver.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), 7)); + displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } } } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(84)); + displayParts.push(ts.keywordPart(85)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 203) { + if (declaration.kind === 205) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(117)); + displayParts.push(ts.keywordPart(118)); displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), 8)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17)); } else { var internalAliasSymbol = typeResolver.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -29347,8 +31204,8 @@ var ts; symbolFlags & 131072 || symbolFlags & 98304 || symbolKind === ScriptElementKind.memberFunctionElement) { - var _allSignatures_1 = type.getCallSignatures(); - addSignatureDisplayParts(_allSignatures_1[0], _allSignatures_1); + var allSignatures = type.getCallSignatures(); + addSignatureDisplayParts(allSignatures[0], allSignatures); } } } @@ -29372,20 +31229,34 @@ var ts; function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); if (symbolKind) { - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart(symbolKind)); - displayParts.push(ts.punctuationPart(17)); + pushTypePart(symbolKind); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } } + function pushTypePart(symbolKind) { + switch (symbolKind) { + case ScriptElementKind.variableElement: + case ScriptElementKind.functionElement: + case ScriptElementKind.letElement: + case ScriptElementKind.constElement: + case ScriptElementKind.constructorImplementationElement: + displayParts.push(ts.textOrKeywordPart(symbolKind)); + return; + default: + displayParts.push(ts.punctuationPart(16)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(17)); + return; + } + } function addSignatureDisplayParts(signature, allSignatures, flags) { displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(16)); displayParts.push(ts.operatorPart(33)); - displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), 7)); + displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); displayParts.push(ts.punctuationPart(17)); @@ -29393,10 +31264,10 @@ var ts; documentation = signature.getDocumentationComment(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var _typeParameterParts = ts.mapToDisplayParts(function (writer) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, _typeParameterParts); + displayParts.push.apply(displayParts, typeParameterParts); } } function getQuickInfoAtPosition(fileName, position) { @@ -29409,11 +31280,11 @@ var ts; var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 64: - case 153: - case 125: - case 92: - case 90: + case 65: + case 155: + case 126: + case 93: + case 91: var type = typeInfoResolver.getTypeAtLocation(node); if (type) { return { @@ -29436,6 +31307,16 @@ var ts; documentation: displayPartsDocumentationsAndKind.documentation }; } + function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + kind: symbolKind, + name: symbolName, + containerKind: undefined, + containerName: containerName + }; + } function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -29446,7 +31327,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [getDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; } var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); if (comment) { @@ -29469,22 +31350,22 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 64 && node.parent === declaration) { + if (node.kind === 65 && node.parent === declaration) { symbol = typeInfoResolver.getAliasedSymbol(symbol); } } - var result = []; - if (node.parent.kind === 219) { + if (node.parent.kind === 222) { var shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); + if (!shorthandSymbol) { + return []; + } var shorthandDeclarations = shorthandSymbol.getDeclarations(); var shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node); var shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol); var shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node); - ts.forEach(shorthandDeclarations, function (declaration) { - result.push(getDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName)); - }); - return result; + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); } + var result = []; var declarations = symbol.getDeclarations(); var symbolName = typeInfoResolver.symbolToString(symbol); var symbolKind = getSymbolKind(symbol, typeInfoResolver, node); @@ -29493,46 +31374,15 @@ var ts; if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { ts.forEach(declarations, function (declaration) { - result.push(getDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); } return result; - function getDefinitionInfo(node, symbolKind, symbolName, containerName) { - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - kind: symbolKind, - name: symbolName, - containerKind: undefined, - containerName: containerName - }; - } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var _declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 133) || - (!selectConstructors && (d.kind === 195 || d.kind === 132 || d.kind === 131))) { - _declarations.push(d); - if (d.body) - definition = d; - } - }); - if (definition) { - result.push(getDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (_declarations.length) { - result.push(getDefinitionInfo(_declarations[_declarations.length - 1], symbolKind, symbolName, containerName)); - return true; - } - return false; - } function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 113) { + if (isNewExpressionTarget(location) || location.kind === 114) { if (symbol.flags & 32) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 196); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 198); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -29544,6 +31394,27 @@ var ts; } return false; } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 135) || + (!selectConstructors && (d.kind === 197 || d.kind === 134 || d.kind === 133))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName)); + return true; + } + return false; + } } function getOccurrencesAtPosition(fileName, position) { synchronizeHostData(); @@ -29552,108 +31423,108 @@ var ts; if (!node) { return undefined; } - if (node.kind === 64 || node.kind === 92 || node.kind === 90 || + if (node.kind === 65 || node.kind === 93 || node.kind === 91 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - return getReferencesForNode(node, [sourceFile], true, false, false); + return convertReferences(getReferencesForNode(node, [sourceFile], true, false, false)); } switch (node.kind) { - case 83: - case 75: - if (hasKind(node.parent, 178)) { + case 84: + case 76: + if (hasKind(node.parent, 180)) { return getIfElseOccurrences(node.parent); } break; - case 89: - if (hasKind(node.parent, 186)) { + case 90: + if (hasKind(node.parent, 188)) { return getReturnOccurrences(node.parent); } break; - case 93: - if (hasKind(node.parent, 190)) { + case 94: + if (hasKind(node.parent, 192)) { return getThrowOccurrences(node.parent); } break; - case 67: - if (hasKind(parent(parent(node)), 191)) { + case 68: + if (hasKind(parent(parent(node)), 193)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 95: - case 80: - if (hasKind(parent(node), 191)) { + case 96: + case 81: + if (hasKind(parent(node), 193)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 91: - if (hasKind(node.parent, 188)) { + case 92: + if (hasKind(node.parent, 190)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 66: - case 72: - if (hasKind(parent(parent(parent(node))), 188)) { + case 67: + case 73: + if (hasKind(parent(parent(parent(node))), 190)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 65: - case 70: - if (hasKind(node.parent, 185) || hasKind(node.parent, 184)) { + case 66: + case 71: + if (hasKind(node.parent, 187) || hasKind(node.parent, 186)) { return getBreakOrContinueStatementOccurences(node.parent); } break; - case 81: - if (hasKind(node.parent, 181) || - hasKind(node.parent, 182) || - hasKind(node.parent, 183)) { + case 82: + if (hasKind(node.parent, 183) || + hasKind(node.parent, 184) || + hasKind(node.parent, 185)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 99: - case 74: - if (hasKind(node.parent, 180) || hasKind(node.parent, 179)) { + case 100: + case 75: + if (hasKind(node.parent, 182) || hasKind(node.parent, 181)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 113: - if (hasKind(node.parent, 133)) { + case 114: + if (hasKind(node.parent, 135)) { return getConstructorOccurrences(node.parent); } break; - case 115: - case 119: - if (hasKind(node.parent, 134) || hasKind(node.parent, 135)) { + case 116: + case 120: + if (hasKind(node.parent, 136) || hasKind(node.parent, 137)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 175)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 177)) { return getModifierOccurrences(node.kind, node.parent); } } return undefined; function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 178) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 180) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 83); - for (var _i = children.length - 1; _i >= 0; _i--) { - if (pushKeywordIf(keywords, children[_i], 75)) { + pushKeywordIf(keywords, children[0], 84); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 76)) { break; } } - if (!hasKind(ifStatement.elseStatement, 178)) { + if (!hasKind(ifStatement.elseStatement, 180)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; - for (var _i_1 = 0; _i_1 < keywords.length; _i_1++) { - if (keywords[_i_1].kind === 75 && _i_1 < keywords.length - 1) { - var elseKeyword = keywords[_i_1]; - var ifKeyword = keywords[_i_1 + 1]; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 76 && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; var shouldHighlightNextKeyword = true; for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { @@ -29667,25 +31538,25 @@ var ts; textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), isWriteAccess: false }); - _i_1++; + i++; continue; } } - result.push(getReferenceEntryFromNode(keywords[_i_1])); + result.push(getReferenceEntryFromNode(keywords[i])); } return result; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 174))) { + if (!(func && hasKind(func.body, 176))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 89); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 90); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 93); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 94); }); return ts.map(keywords, getReferenceEntryFromNode); } @@ -29696,11 +31567,11 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 93); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 94); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 89); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 90); }); } return ts.map(keywords, getReferenceEntryFromNode); @@ -29710,10 +31581,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 190) { + if (node.kind === 192) { statementAccumulator.push(node); } - else if (node.kind === 191) { + else if (node.kind === 193) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -29734,39 +31605,39 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var _parent = child.parent; - if (ts.isFunctionBlock(_parent) || _parent.kind === 221) { - return _parent; + var parent_9 = child.parent; + if (ts.isFunctionBlock(parent_9) || parent_9.kind === 224) { + return parent_9; } - if (_parent.kind === 191) { - var tryStatement = _parent; + if (parent_9.kind === 193) { + var tryStatement = parent_9; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = _parent; + child = parent_9; } return undefined; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 95); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 96); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 67); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 68); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 80, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 80); + var finallyKeyword = ts.findChildOfKind(tryStatement, 81, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 81); } return ts.map(keywords, getReferenceEntryFromNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 81, 99, 74)) { - if (loopNode.kind === 179) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82, 100, 75)) { + if (loopNode.kind === 181) { var loopTokens = loopNode.getChildren(); - for (var _i = loopTokens.length - 1; _i >= 0; _i--) { - if (pushKeywordIf(keywords, loopTokens[_i], 99)) { + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 100)) { break; } } @@ -29775,20 +31646,20 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 65, 70); + pushKeywordIf(keywords, statement.getFirstToken(), 66, 71); } }); return ts.map(keywords, getReferenceEntryFromNode); } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 91); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 92); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 66, 72); + pushKeywordIf(keywords, clause.getFirstToken(), 67, 73); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 65); + pushKeywordIf(keywords, statement.getFirstToken(), 66); } }); }); @@ -29798,13 +31669,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { + case 183: + case 184: + case 185: case 181: case 182: - case 183: - case 179: - case 180: return getLoopBreakContinueOccurrences(owner); - case 188: + case 190: return getSwitchCaseDefaultOccurrences(owner); } } @@ -29815,7 +31686,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 185 || node.kind === 184) { + if (node.kind === 187 || node.kind === 186) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -29829,23 +31700,23 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var _node = statement.parent; _node; _node = _node.parent) { - switch (_node.kind) { - case 188: - if (statement.kind === 184) { + for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { + switch (node_1.kind) { + case 190: + if (statement.kind === 186) { continue; } - case 181: - case 182: case 183: - case 180: - case 179: - if (!statement.label || isLabeledBy(_node, statement.label.text)) { - return _node; + case 184: + case 185: + case 182: + case 181: + if (!statement.label || isLabeledBy(node_1, statement.label.text)) { + return node_1; } break; default: - if (ts.isFunctionLike(_node)) { + if (ts.isFunctionLike(node_1)) { return undefined; } break; @@ -29858,38 +31729,38 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 113); + return pushKeywordIf(keywords, token, 114); }); }); return ts.map(keywords, getReferenceEntryFromNode); } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 134); - tryPushAccessorKeyword(accessorDeclaration.symbol, 135); + tryPushAccessorKeyword(accessorDeclaration.symbol, 136); + tryPushAccessorKeyword(accessorDeclaration.symbol, 137); return ts.map(keywords, getReferenceEntryFromNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 115, 119); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 120); }); } } } function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; - if (declaration.flags & 112) { - if (!(container.kind === 196 || - (declaration.kind === 128 && hasKind(container, 133)))) { + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 198 || + (declaration.kind === 129 && hasKind(container, 135)))) { return undefined; } } - else if (declaration.flags & 128) { - if (container.kind !== 196) { + else if (modifier === 110) { + if (container.kind !== 198) { return undefined; } } - else if (declaration.flags & (1 | 2)) { - if (!(container.kind === 201 || container.kind === 221)) { + else if (modifier === 78 || modifier === 115) { + if (!(container.kind === 203 || container.kind === 224)) { return undefined; } } @@ -29900,18 +31771,18 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 201: - case 221: + case 203: + case 224: nodes = container.statements; break; - case 133: + case 135: nodes = container.parameters.concat(container.parent.members); break; - case 196: + case 198: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 133 && member; + return member.kind === 135 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -29929,17 +31800,17 @@ var ts; return ts.map(keywords, getReferenceEntryFromNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 108: - return 16; - case 106: - return 32; - case 107: - return 64; case 109: + return 16; + case 107: + return 32; + case 108: + return 64; + case 110: return 128; - case 77: + case 78: return 1; - case 114: + case 115: return 2; default: ts.Debug.fail(); @@ -29964,46 +31835,63 @@ var ts; return false; } } + function convertReferences(referenceSymbols) { + if (!referenceSymbols) { + return undefined; + } + var referenceEntries = []; + for (var _i = 0, _n = referenceSymbols.length; _i < _n; _i++) { + var referenceSymbol = referenceSymbols[_i]; + ts.addRange(referenceEntries, referenceSymbol.references); + } + return referenceEntries; + } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return findReferences(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - return findReferences(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return convertReferences(referencedSymbols); } - function findReferences(fileName, position, findInStrings, findInComments) { + function findReferences(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); + } + function findReferencedSymbols(fileName, position, findInStrings, findInComments) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, position); if (!node) { return undefined; } - if (node.kind !== 64 && + if (node.kind !== 65 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 64 || node.kind === 7 || node.kind === 8); + ts.Debug.assert(node.kind === 65 || node.kind === 7 || node.kind === 8); return getReferencesForNode(node, program.getSourceFiles(), false, findInStrings, findInComments); } function getReferencesForNode(node, sourceFiles, searchOnlyInCurrentFile, findInStrings, findInComments) { if (isLabelName(node)) { if (isJumpStatementTarget(node)) { var labelDefinition = getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : [getReferenceEntryFromNode(node)]; + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; } else { return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 92) { + if (node.kind === 93) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 90) { + if (node.kind === 91) { return getReferencesForSuperKeyword(node); } var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { - return [getReferenceEntryFromNode(node)]; + return undefined; } var declarations = symbol.declarations; if (!declarations || !declarations.length) { @@ -30013,15 +31901,16 @@ var ts; var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); var declaredName = getDeclaredName(symbol, node); var scope = getSymbolScope(symbol); + var symbolToIndex = []; if (scope) { result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { if (searchOnlyInCurrentFile) { ts.Debug.assert(sourceFiles.length === 1); result = []; - getReferencesInNode(sourceFiles[0], symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(sourceFiles[0], symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { var internedName = getInternedName(symbol, node, declarations); @@ -30030,48 +31919,64 @@ var ts; var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } }); } } return result; + function getDefinition(symbol) { + var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), typeInfoResolver, node); + var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + return { + containerKind: "", + containerName: "", + name: name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0) + }; + } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 208 || location.parent.kind === 212) && + (location.parent.kind === 210 || location.parent.kind === 214) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 208 || declaration.kind === 212; + return declaration.kind === 210 || declaration.kind === 214; }); } function getDeclaredName(symbol, location) { - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 160 ? d : undefined; }); - var _name; + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 162 ? d : undefined; }); + var name; if (functionExpression && functionExpression.name) { - _name = functionExpression.name.text; + name = functionExpression.name.text; } if (isImportOrExportSpecifierName(location)) { return location.getText(); } - _name = typeInfoResolver.symbolToString(symbol); - return stripQuotes(_name); + name = typeInfoResolver.symbolToString(symbol); + return stripQuotes(name); } function getInternedName(symbol, location, declarations) { if (isImportOrExportSpecifierName(location)) { return location.getText(); } - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 160 ? d : undefined; }); - var _name = functionExpression && functionExpression.name + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 162 ? d : undefined; }); + var name = functionExpression && functionExpression.name ? functionExpression.name.text : symbol.name; - return stripQuotes(_name); + return stripQuotes(name); } function stripQuotes(name) { - var _length = name.length; - if (_length >= 2 && name.charCodeAt(0) === 34 && name.charCodeAt(_length - 1) === 34) { - return name.substring(1, _length - 1); + var length = name.length; + if (length >= 2 && name.charCodeAt(0) === 34 && name.charCodeAt(length - 1) === 34) { + return name.substring(1, length - 1); } ; return name; @@ -30080,7 +31985,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 196); + return ts.getAncestor(privateDeclaration, 198); } } if (symbol.flags & 8388608) { @@ -30089,25 +31994,25 @@ var ts; if (symbol.parent || (symbol.flags & 268435456)) { return undefined; } - var _scope = undefined; - var _declarations = symbol.getDeclarations(); - if (_declarations) { - for (var _i = 0, _n = _declarations.length; _i < _n; _i++) { - var declaration = _declarations[_i]; + var scope = undefined; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, _n = declarations.length; _i < _n; _i++) { + var declaration = declarations[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; } - if (_scope && _scope !== container) { + if (scope && scope !== container) { return undefined; } - if (container.kind === 221 && !ts.isExternalModule(container)) { + if (container.kind === 224 && !ts.isExternalModule(container)) { return undefined; } - _scope = container; + scope = container; } } - return _scope; + return scope; } function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { var positions = []; @@ -30132,27 +32037,35 @@ var ts; return positions; } function getLabelReferencesInNode(container, targetLabel) { - var _result = []; + var references = []; var sourceFile = container.getSourceFile(); var labelName = targetLabel.text; var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.getWidth() !== labelName.length) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { return; } - if (_node === targetLabel || - (isJumpStatementTarget(_node) && getTargetLabel(_node, labelName) === targetLabel)) { - _result.push(getReferenceEntryFromNode(_node)); + if (node === targetLabel || + (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); } }); - return _result; + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) + }; + return [{ definition: definition, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 64: + case 65: return node.getWidth() === searchSymbolName.length; case 8: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -30169,7 +32082,7 @@ var ts; } return false; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result) { + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { var sourceFile = container.getSourceFile(); var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { - result.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); + var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } } }); } + return; + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol), + references: [] + }); + } + return result[index]; + } function isInString(position) { var token = ts.getTokenAtPosition(sourceFile, position); return token && token.kind === 8 && position > token.getStart(); @@ -30232,105 +32165,116 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 130: - case 129: case 132: case 131: - case 133: case 134: + case 133: case 135: + case 136: + case 137: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; default: return undefined; } - var _result = []; + var references = []; var sourceFile = searchSpaceNode.getSourceFile(); var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.kind !== 90) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 91) { return; } - var container = ts.getSuperContainer(_node, false); + var container = ts.getSuperContainer(node, false); if (container && (128 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - _result.push(getReferenceEntryFromNode(_node)); + references.push(getReferenceEntryFromNode(node)); } }); - return _result; + var definition = getDefinition(searchSpaceNode.symbol); + return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { - case 132: - case 131: + case 134: + case 133: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } - case 130: - case 129: - case 133: - case 134: + case 132: + case 131: case 135: + case 136: + case 137: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 221: + case 224: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 195: - case 160: + case 197: + case 162: break; default: return undefined; } - var _result = []; + var references = []; var possiblePositions; - if (searchSpaceNode.kind === 221) { + if (searchSpaceNode.kind === 224) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, _result); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); }); } else { var sourceFile = searchSpaceNode.getSourceFile(); possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, _result); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); } - return _result; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) + }, + references: references + }]; function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.kind !== 92) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 93) { return; } - var container = ts.getThisContainer(_node, false); + var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 160: - case 195: + case 162: + case 197: if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 132: - case 131: + case 134: + case 133: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 196: + case 198: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 221: - if (container.kind === 221 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(_node)); + case 224: + if (container.kind === 224 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); } break; } @@ -30338,37 +32282,37 @@ var ts; } } function populateSearchSymbolSet(symbol, location) { - var _result = [symbol]; + var result = [symbol]; if (isImportOrExportSpecifierImportSymbol(symbol)) { - _result.push(typeInfoResolver.getAliasedSymbol(symbol)); + result.push(typeInfoResolver.getAliasedSymbol(symbol)); } if (isNameOfPropertyAssignment(location)) { ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - _result.push.apply(_result, typeInfoResolver.getRootSymbols(contextualSymbol)); + result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol)); }); var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(location.parent); if (shorthandValueSymbol) { - _result.push(shorthandValueSymbol); + result.push(shorthandValueSymbol); } } ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) { if (rootSymbol !== symbol) { - _result.push(rootSymbol); + result.push(rootSymbol); } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), _result); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); } }); - return _result; + return result; } function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 196) { + if (declaration.kind === 198) { getPropertySymbolFromTypeReference(ts.getClassBaseTypeNode(declaration)); ts.forEach(ts.getClassImplementedTypeNodes(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 197) { + else if (declaration.kind === 199) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -30387,57 +32331,59 @@ var ts; } } } - function isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation) { + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { if (searchSymbols.indexOf(referenceSymbol) >= 0) { - return true; + return referenceSymbol; } - if (isImportOrExportSpecifierImportSymbol(referenceSymbol) && - searchSymbols.indexOf(typeInfoResolver.getAliasedSymbol(referenceSymbol)) >= 0) { - return true; + if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + var aliasedSymbol = typeInfoResolver.getAliasedSymbol(referenceSymbol); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } } if (isNameOfPropertyAssignment(referenceLocation)) { return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { - return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0; }); + return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); }); } return ts.forEach(typeInfoResolver.getRootSymbols(referenceSymbol), function (rootSymbol) { if (searchSymbols.indexOf(rootSymbol) >= 0) { - return true; + return rootSymbol; } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - var _result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), _result); - return ts.forEach(_result, function (s) { return searchSymbols.indexOf(s) >= 0; }); + var result_2 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_2); + return ts.forEach(result_2, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } - return false; + return undefined; }); } function getPropertySymbolsFromContextualType(node) { if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeInfoResolver.getContextualType(objectLiteral); - var _name = node.text; + var name_20 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(_name); + var unionProperty = contextualType.getProperty(name_20); if (unionProperty) { return [unionProperty]; } else { - var _result = []; + var result_3 = []; ts.forEach(contextualType.types, function (t) { - var _symbol = t.getProperty(_name); - if (_symbol) { - _result.push(_symbol); + var symbol = t.getProperty(name_20); + if (symbol) { + result_3.push(symbol); } }); - return _result; + return result_3; } } else { - var _symbol = contextualType.getProperty(_name); - if (_symbol) { - return [_symbol]; + var symbol_1 = contextualType.getProperty(name_20); + if (symbol_1) { + return [symbol_1]; } } } @@ -30475,17 +32421,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 64 && ts.isDeclarationName(node)) { + if (node.kind === 65 && ts.isDeclarationName(node)) { return true; } - var _parent = node.parent; - if (_parent) { - if (_parent.kind === 166 || _parent.kind === 165) { + var parent = node.parent; + if (parent) { + if (parent.kind === 168 || parent.kind === 167) { return true; } - else if (_parent.kind === 167 && _parent.left === node) { - var operator = _parent.operatorToken.kind; - return 52 <= operator && operator <= 63; + else if (parent.kind === 169 && parent.left === node) { + var operator = parent.operatorToken.kind; + return 53 <= operator && operator <= 64; } } return false; @@ -30495,7 +32441,7 @@ var ts; return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); } function containErrors(diagnostics) { - return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === 1; }); + return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); } function getEmitOutput(fileName) { synchronizeHostData(); @@ -30516,33 +32462,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 128: - case 193: - case 150: - case 130: case 129: - case 218: - case 219: - case 220: + case 195: + case 152: case 132: case 131: - case 133: + case 221: + case 222: + case 223: case 134: + case 133: case 135: - case 195: - case 160: - case 161: - case 217: - return 1; - case 127: + case 136: + case 137: case 197: - case 198: - case 143: - return 2; - case 196: + case 162: + case 163: + case 220: + return 1; + case 128: case 199: - return 1 | 2; case 200: + case 145: + return 2; + case 198: + case 201: + return 1 | 2; + case 202: if (node.name.kind === 8) { return 4 | 1; } @@ -30552,14 +32498,14 @@ var ts; else { return 4; } - case 207: - case 208: - case 203: - case 204: case 209: case 210: + case 205: + case 206: + case 211: + case 212: return 1 | 2 | 4; - case 221: + case 224: return 4 | 1; } return 1 | 2 | 4; @@ -30569,35 +32515,35 @@ var ts; if (isRightSideOfQualifiedName(node)) { node = node.parent; } - return node.parent.kind === 139; + return node.parent.kind === 141; } function isNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 125) { - while (root.parent && root.parent.kind === 125) + if (root.parent.kind === 126) { + while (root.parent && root.parent.kind === 126) root = root.parent; isLastClause = root.right === node; } - return root.parent.kind === 139 && !isLastClause; + return root.parent.kind === 141 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 125) { + while (node.parent.kind === 126) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 64); - if (node.parent.kind === 125 && + ts.Debug.assert(node.kind === 65); + if (node.parent.kind === 126 && node.parent.right === node && - node.parent.parent.kind === 203) { + node.parent.parent.kind === 205) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 211) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -30631,15 +32577,15 @@ var ts; return; } switch (node.kind) { - case 153: - case 125: + case 155: + case 126: case 8: - case 79: - case 94: - case 88: - case 90: - case 92: - case 64: + case 80: + case 95: + case 89: + case 91: + case 93: + case 65: break; default: return; @@ -30650,7 +32596,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 200 && + if (nodeForStartPos.parent.parent.kind === 202 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -30706,13 +32652,13 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 200 && ts.getModuleInstanceState(declaration) == 1; + return declaration.kind === 202 && ts.getModuleInstanceState(declaration) == 1; }); } } function processNode(node) { if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 64 && node.getWidth() > 0) { + if (node.kind === 65 && node.getWidth() > 0) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); @@ -30823,17 +32769,17 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 52) { - if (token.parent.kind === 193 || - token.parent.kind === 130 || - token.parent.kind === 128) { + if (tokenKind === 53) { + if (token.parent.kind === 195 || + token.parent.kind === 132 || + token.parent.kind === 129) { return ClassificationTypeNames.operator; } } - if (token.parent.kind === 167 || - token.parent.kind === 165 || - token.parent.kind === 166 || - token.parent.kind === 168) { + if (token.parent.kind === 169 || + token.parent.kind === 167 || + token.parent.kind === 168 || + token.parent.kind === 170) { return ClassificationTypeNames.operator; } } @@ -30851,30 +32797,30 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return ClassificationTypeNames.stringLiteral; } - else if (tokenKind === 64) { + else if (tokenKind === 65) { if (token) { switch (token.parent.kind) { - case 196: + case 198: if (token.parent.name === token) { return ClassificationTypeNames.className; } return; - case 127: + case 128: if (token.parent.name === token) { return ClassificationTypeNames.typeParameterName; } return; - case 197: + case 199: if (token.parent.name === token) { return ClassificationTypeNames.interfaceName; } return; - case 199: + case 201: if (token.parent.name === token) { return ClassificationTypeNames.enumName; } return; - case 200: + case 202: if (token.parent.name === token) { return ClassificationTypeNames.moduleName; } @@ -30993,9 +32939,9 @@ var ts; continue; } var descriptor = undefined; - for (var _i = 0, n = descriptors.length; _i < n; _i++) { - if (matchArray[_i + firstDescriptorCaptureIndex]) { - descriptor = descriptors[_i]; + for (var i = 0, n = descriptors.length; i < n; i++) { + if (matchArray[i + firstDescriptorCaptureIndex]) { + descriptor = descriptors[i]; } } ts.Debug.assert(descriptor !== undefined); @@ -31015,15 +32961,17 @@ var ts; return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); } function getTodoCommentsRegExp() { + // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to + // filter them out later in the final result array. var singleLineCommentStart = /(?:\/\/+\s*)/.source; var multiLineCommentStart = /(?:\/\*+\s*)/.source; var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; - var _preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; var messagePortion = "(" + literals + messageRemainder + ")"; - var regExpString = _preamble + messagePortion + endOfLineOrEndOfComment; + var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { @@ -31036,7 +32984,7 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 64) { + if (node && node.kind === 65) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -31045,8 +32993,8 @@ var ts; if (defaultLibFileName) { for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var current = declarations[_i]; - var _sourceFile = current.getSourceFile(); - if (_sourceFile && getCanonicalFileName(ts.normalizePath(_sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { + var sourceFile_1 = current.getSourceFile(); + if (sourceFile_1 && getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } } @@ -31093,6 +33041,7 @@ var ts; getQuickInfoAtPosition: getQuickInfoAtPosition, getDefinitionAtPosition: getDefinitionAtPosition, getReferencesAtPosition: getReferencesAtPosition, + findReferences: findReferences, getOccurrencesAtPosition: getOccurrencesAtPosition, getNameOrDottedNameSpan: getNameOrDottedNameSpan, getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, @@ -31126,13 +33075,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 64: + case 65: nameTable[node.text] = node.text; break; case 8: case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 213 || + node.parent.kind === 216 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -31145,40 +33094,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 154 && + node.parent.kind === 156 && node.parent.argumentExpression === node; } function createClassifier() { - var _scanner = ts.createScanner(2, false); + var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[64] = true; + noRegexTable[65] = true; noRegexTable[8] = true; noRegexTable[7] = true; noRegexTable[9] = true; - noRegexTable[92] = true; + noRegexTable[93] = true; noRegexTable[38] = true; noRegexTable[39] = true; noRegexTable[17] = true; noRegexTable[19] = true; noRegexTable[15] = true; - noRegexTable[94] = true; - noRegexTable[79] = true; + noRegexTable[95] = true; + noRegexTable[80] = true; var templateStack = []; - function isAccessibilityModifier(kind) { - switch (kind) { - case 108: - case 106: - case 107: - return true; - } - return false; - } function canFollow(keyword1, keyword2) { - if (isAccessibilityModifier(keyword1)) { - if (keyword2 === 115 || - keyword2 === 119 || - keyword2 === 113 || - keyword2 === 109) { + if (ts.isAccessibilityModifier(keyword1)) { + if (keyword2 === 116 || + keyword2 === 120 || + keyword2 === 114 || + keyword2 === 110) { return true; } return false; @@ -31216,40 +33156,40 @@ var ts; templateStack.push(11); break; } - _scanner.setText(text); + scanner.setText(text); var result = { finalLexState: 0, entries: [] }; var angleBracketStack = 0; do { - token = _scanner.scan(); + token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 36 || token === 56) && !noRegexTable[lastNonTriviaToken]) { - if (_scanner.reScanSlashToken() === 9) { + if ((token === 36 || token === 57) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 9) { token = 9; } } else if (lastNonTriviaToken === 20 && isKeyword(token)) { - token = 64; + token = 65; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 64; + token = 65; } - else if (lastNonTriviaToken === 64 && + else if (lastNonTriviaToken === 65 && token === 24) { angleBracketStack++; } else if (token === 25 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 111 || - token === 120 || - token === 118 || - token === 112 || - token === 121) { + else if (token === 112 || + token === 121 || + token === 119 || + token === 113 || + token === 122) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 64; + token = 65; } } else if (token === 11) { @@ -31264,7 +33204,7 @@ var ts; if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); if (lastTemplateStackToken === 11) { - token = _scanner.reScanTemplateToken(); + token = scanner.reScanTemplateToken(); if (token === 13) { templateStack.pop(); } @@ -31284,13 +33224,13 @@ var ts; } while (token !== 1); return result; function processToken() { - var start = _scanner.getTokenPos(); - var end = _scanner.getTextPos(); + var start = scanner.getTokenPos(); + var end = scanner.getTextPos(); addResult(end - start, classFromKind(token)); if (end >= text.length) { if (token === 8) { - var tokenText = _scanner.getTokenText(); - if (_scanner.isUnterminated()) { + var tokenText = scanner.getTokenText(); + if (scanner.isUnterminated()) { var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92) { @@ -31305,12 +33245,12 @@ var ts; } } else if (token === 3) { - if (_scanner.isUnterminated()) { + if (scanner.isUnterminated()) { result.finalLexState = 1; } } else if (ts.isTemplateLiteralKind(token)) { - if (_scanner.isUnterminated()) { + if (scanner.isUnterminated()) { if (token === 13) { result.finalLexState = 5; } @@ -31350,8 +33290,8 @@ var ts; case 25: case 26: case 27: + case 87: case 86: - case 85: case 28: case 29: case 30: @@ -31361,18 +33301,18 @@ var ts; case 44: case 48: case 49: - case 62: - case 61: case 63: - case 58: + case 62: + case 64: case 59: case 60: - case 53: + case 61: case 54: case 55: case 56: case 57: - case 52: + case 58: + case 53: case 23: return true; default: @@ -31393,38 +33333,38 @@ var ts; } } function isKeyword(token) { - return token >= 65 && token <= 124; + return token >= 66 && token <= 125; } function classFromKind(token) { if (isKeyword(token)) { - return 1; + return TokenClass.Keyword; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 2; + return TokenClass.Operator; } - else if (token >= 14 && token <= 63) { - return 0; + else if (token >= 14 && token <= 64) { + return TokenClass.Punctuation; } switch (token) { case 7: - return 6; + return TokenClass.NumberLiteral; case 8: - return 7; + return TokenClass.StringLiteral; case 9: - return 8; + return TokenClass.RegExpLiteral; case 6: case 3: case 2: - return 3; + return TokenClass.Comment; case 5: case 4: - return 4; - case 64: + return TokenClass.Whitespace; + case 65: default: if (ts.isTemplateLiteralKind(token)) { - return 7; + return TokenClass.StringLiteral; } - return 5; + return TokenClass.Identifier; } } return { getClassificationsForLine: getClassificationsForLine }; @@ -31442,7 +33382,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 221 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 224 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -31458,6 +33398,9 @@ var ts; } initializeServices(); })(ts || (ts = {})); +// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. +// See LICENSE.txt in the project root for complete license information. +/// var ts; (function (ts) { var BreakpointResolver; @@ -31496,98 +33439,101 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return spanInPreviousNode(node); } - if (node.parent.kind === 181) { + if (node.parent.kind === 183) { return textSpan(node); } - if (node.parent.kind === 167 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 169 && node.parent.operatorToken.kind === 23) { return textSpan(node); } - if (node.parent.kind == 161 && node.parent.body == node) { + if (node.parent.kind == 163 && node.parent.body == node) { return textSpan(node); } } switch (node.kind) { - case 175: + case 177: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 193: - case 130: - case 129: - return spanInVariableDeclaration(node); - case 128: - return spanInParameterDeclaration(node); case 195: case 132: case 131: + return spanInVariableDeclaration(node); + case 129: + return spanInParameterDeclaration(node); + case 197: case 134: - case 135: case 133: - case 160: - case 161: + case 136: + case 137: + case 135: + case 162: + case 163: return spanInFunctionDeclaration(node); - case 174: + case 176: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 201: + case 203: return spanInBlock(node); - case 217: + case 220: return spanInBlock(node.block); - case 177: + case 179: return textSpan(node.expression); - case 186: + case 188: return textSpan(node.getChildAt(0), node.expression); + case 182: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 181: + return spanInNode(node.statement); + case 194: + return textSpan(node.getChildAt(0)); case 180: return textSpan(node, ts.findNextToken(node.expression, node)); - case 179: - return spanInNode(node.statement); - case 192: - return textSpan(node.getChildAt(0)); - case 178: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 189: - return spanInNode(node.statement); - case 185: - case 184: - return textSpan(node.getChildAt(0), node.label); - case 181: - return spanInForStatement(node); - case 182: - case 183: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 188: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 214: - case 215: - return spanInNode(node.statements[0]); case 191: - return spanInBlock(node.tryBlock); + return spanInNode(node.statement); + case 187: + case 186: + return textSpan(node.getChildAt(0), node.label); + case 183: + return spanInForStatement(node); + case 184: + case 185: + return textSpan(node, ts.findNextToken(node.expression, node)); case 190: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 217: + case 218: + return spanInNode(node.statements[0]); + case 193: + return spanInBlock(node.tryBlock); + case 192: return textSpan(node, node.expression); - case 209: + case 211: + if (!node.expression) { + return undefined; + } return textSpan(node, node.expression); - case 203: + case 205: return textSpan(node, node.moduleReference); - case 204: + case 206: return textSpan(node, node.moduleSpecifier); - case 210: + case 212: return textSpan(node, node.moduleSpecifier); - case 200: + case 202: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 196: - case 199: - case 220: - case 155: - case 156: - return textSpan(node); - case 187: - return spanInNode(node.statement); - case 197: case 198: + case 201: + case 223: + case 157: + case 158: + return textSpan(node); + case 189: + return spanInNode(node.statement); + case 199: + case 200: return undefined; case 22: case 1: @@ -31607,17 +33553,17 @@ var ts; case 25: case 24: return spanInGreaterThanOrLessThanToken(node); - case 99: + case 100: return spanInWhileKeyword(node); - case 75: - case 67: - case 80: + case 76: + case 68: + case 81: return spanInNextNode(node); default: - if (node.parent.kind === 218 && node.parent.name === node) { + if (node.parent.kind === 221 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 158 && node.parent.type === node) { + if (node.parent.kind === 160 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -31627,12 +33573,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 182 || - variableDeclaration.parent.parent.kind === 183) { + if (variableDeclaration.parent.parent.kind === 184 || + variableDeclaration.parent.parent.kind === 185) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 175; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 181 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 177; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 183 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -31678,7 +33624,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 196 && functionDeclaration.kind !== 133); + (functionDeclaration.parent.kind === 198 && functionDeclaration.kind !== 135); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -31698,23 +33644,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 200: + case 202: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 180: - case 178: case 182: - case 183: + case 180: + case 184: + case 185: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 181: + case 183: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 194) { + if (forStatement.initializer.kind === 196) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -31733,34 +33679,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 199: + case 201: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 196: + case 198: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 202: + case 204: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 201: + case 203: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 199: - case 196: + case 201: + case 198: return textSpan(node); - case 174: + case 176: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 217: + case 220: return spanInNode(node.parent.statements[node.parent.statements.length - 1]); ; - case 202: + case 204: var caseBlock = node.parent; var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1]; if (lastClause) { @@ -31772,24 +33718,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 160: - case 195: - case 161: - case 132: - case 131: + case 162: + case 197: + case 163: case 134: - case 135: case 133: - case 180: - case 179: + case 136: + case 137: + case 135: + case 182: case 181: + case 183: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -31797,19 +33743,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 218) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 221) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 158) { + if (node.parent.kind === 160) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -31819,6 +33765,21 @@ var ts; BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var debugObjectHost = this; var ts; (function (ts) { @@ -32103,6 +34064,12 @@ var ts; return _this.languageService.getReferencesAtPosition(fileName, position); }); }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { + return _this.languageService.findReferences(fileName, position); + }); + }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { @@ -32312,3 +34279,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); +var toolsVersion = "1.4"; diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index a557e814a79..6046a83da13 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -74,192 +74,195 @@ declare module ts { BarBarToken = 49, QuestionToken = 50, ColonToken = 51, - EqualsToken = 52, - PlusEqualsToken = 53, - MinusEqualsToken = 54, - AsteriskEqualsToken = 55, - SlashEqualsToken = 56, - PercentEqualsToken = 57, - LessThanLessThanEqualsToken = 58, - GreaterThanGreaterThanEqualsToken = 59, - GreaterThanGreaterThanGreaterThanEqualsToken = 60, - AmpersandEqualsToken = 61, - BarEqualsToken = 62, - CaretEqualsToken = 63, - Identifier = 64, - BreakKeyword = 65, - CaseKeyword = 66, - CatchKeyword = 67, - ClassKeyword = 68, - ConstKeyword = 69, - ContinueKeyword = 70, - DebuggerKeyword = 71, - DefaultKeyword = 72, - DeleteKeyword = 73, - DoKeyword = 74, - ElseKeyword = 75, - EnumKeyword = 76, - ExportKeyword = 77, - ExtendsKeyword = 78, - FalseKeyword = 79, - FinallyKeyword = 80, - ForKeyword = 81, - FunctionKeyword = 82, - IfKeyword = 83, - ImportKeyword = 84, - InKeyword = 85, - InstanceOfKeyword = 86, - NewKeyword = 87, - NullKeyword = 88, - ReturnKeyword = 89, - SuperKeyword = 90, - SwitchKeyword = 91, - ThisKeyword = 92, - ThrowKeyword = 93, - TrueKeyword = 94, - TryKeyword = 95, - TypeOfKeyword = 96, - VarKeyword = 97, - VoidKeyword = 98, - WhileKeyword = 99, - WithKeyword = 100, - AsKeyword = 101, - ImplementsKeyword = 102, - InterfaceKeyword = 103, - LetKeyword = 104, - PackageKeyword = 105, - PrivateKeyword = 106, - ProtectedKeyword = 107, - PublicKeyword = 108, - StaticKeyword = 109, - YieldKeyword = 110, - AnyKeyword = 111, - BooleanKeyword = 112, - ConstructorKeyword = 113, - DeclareKeyword = 114, - GetKeyword = 115, - ModuleKeyword = 116, - RequireKeyword = 117, - NumberKeyword = 118, - SetKeyword = 119, - StringKeyword = 120, - SymbolKeyword = 121, - TypeKeyword = 122, - FromKeyword = 123, - OfKeyword = 124, - QualifiedName = 125, - ComputedPropertyName = 126, - TypeParameter = 127, - Parameter = 128, - PropertySignature = 129, - PropertyDeclaration = 130, - MethodSignature = 131, - MethodDeclaration = 132, - Constructor = 133, - GetAccessor = 134, - SetAccessor = 135, - CallSignature = 136, - ConstructSignature = 137, - IndexSignature = 138, - TypeReference = 139, - FunctionType = 140, - ConstructorType = 141, - TypeQuery = 142, - TypeLiteral = 143, - ArrayType = 144, - TupleType = 145, - UnionType = 146, - ParenthesizedType = 147, - ObjectBindingPattern = 148, - ArrayBindingPattern = 149, - BindingElement = 150, - ArrayLiteralExpression = 151, - ObjectLiteralExpression = 152, - PropertyAccessExpression = 153, - ElementAccessExpression = 154, - CallExpression = 155, - NewExpression = 156, - TaggedTemplateExpression = 157, - TypeAssertionExpression = 158, - ParenthesizedExpression = 159, - FunctionExpression = 160, - ArrowFunction = 161, - DeleteExpression = 162, - TypeOfExpression = 163, - VoidExpression = 164, - PrefixUnaryExpression = 165, - PostfixUnaryExpression = 166, - BinaryExpression = 167, - ConditionalExpression = 168, - TemplateExpression = 169, - YieldExpression = 170, - SpreadElementExpression = 171, - OmittedExpression = 172, - TemplateSpan = 173, - Block = 174, - VariableStatement = 175, - EmptyStatement = 176, - ExpressionStatement = 177, - IfStatement = 178, - DoStatement = 179, - WhileStatement = 180, - ForStatement = 181, - ForInStatement = 182, - ForOfStatement = 183, - ContinueStatement = 184, - BreakStatement = 185, - ReturnStatement = 186, - WithStatement = 187, - SwitchStatement = 188, - LabeledStatement = 189, - ThrowStatement = 190, - TryStatement = 191, - DebuggerStatement = 192, - VariableDeclaration = 193, - VariableDeclarationList = 194, - FunctionDeclaration = 195, - ClassDeclaration = 196, - InterfaceDeclaration = 197, - TypeAliasDeclaration = 198, - EnumDeclaration = 199, - ModuleDeclaration = 200, - ModuleBlock = 201, - CaseBlock = 202, - ImportEqualsDeclaration = 203, - ImportDeclaration = 204, - ImportClause = 205, - NamespaceImport = 206, - NamedImports = 207, - ImportSpecifier = 208, - ExportAssignment = 209, - ExportDeclaration = 210, - NamedExports = 211, - ExportSpecifier = 212, - ExternalModuleReference = 213, - CaseClause = 214, - DefaultClause = 215, - HeritageClause = 216, - CatchClause = 217, - PropertyAssignment = 218, - ShorthandPropertyAssignment = 219, - EnumMember = 220, - SourceFile = 221, - SyntaxList = 222, - Count = 223, - FirstAssignment = 52, - LastAssignment = 63, - FirstReservedWord = 65, - LastReservedWord = 100, - FirstKeyword = 65, - LastKeyword = 124, - FirstFutureReservedWord = 102, - LastFutureReservedWord = 110, - FirstTypeNode = 139, - LastTypeNode = 147, + AtToken = 52, + EqualsToken = 53, + PlusEqualsToken = 54, + MinusEqualsToken = 55, + AsteriskEqualsToken = 56, + SlashEqualsToken = 57, + PercentEqualsToken = 58, + LessThanLessThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, + AmpersandEqualsToken = 62, + BarEqualsToken = 63, + CaretEqualsToken = 64, + Identifier = 65, + BreakKeyword = 66, + CaseKeyword = 67, + CatchKeyword = 68, + ClassKeyword = 69, + ConstKeyword = 70, + ContinueKeyword = 71, + DebuggerKeyword = 72, + DefaultKeyword = 73, + DeleteKeyword = 74, + DoKeyword = 75, + ElseKeyword = 76, + EnumKeyword = 77, + ExportKeyword = 78, + ExtendsKeyword = 79, + FalseKeyword = 80, + FinallyKeyword = 81, + ForKeyword = 82, + FunctionKeyword = 83, + IfKeyword = 84, + ImportKeyword = 85, + InKeyword = 86, + InstanceOfKeyword = 87, + NewKeyword = 88, + NullKeyword = 89, + ReturnKeyword = 90, + SuperKeyword = 91, + SwitchKeyword = 92, + ThisKeyword = 93, + ThrowKeyword = 94, + TrueKeyword = 95, + TryKeyword = 96, + TypeOfKeyword = 97, + VarKeyword = 98, + VoidKeyword = 99, + WhileKeyword = 100, + WithKeyword = 101, + AsKeyword = 102, + ImplementsKeyword = 103, + InterfaceKeyword = 104, + LetKeyword = 105, + PackageKeyword = 106, + PrivateKeyword = 107, + ProtectedKeyword = 108, + PublicKeyword = 109, + StaticKeyword = 110, + YieldKeyword = 111, + AnyKeyword = 112, + BooleanKeyword = 113, + ConstructorKeyword = 114, + DeclareKeyword = 115, + GetKeyword = 116, + ModuleKeyword = 117, + RequireKeyword = 118, + NumberKeyword = 119, + SetKeyword = 120, + StringKeyword = 121, + SymbolKeyword = 122, + TypeKeyword = 123, + FromKeyword = 124, + OfKeyword = 125, + QualifiedName = 126, + ComputedPropertyName = 127, + TypeParameter = 128, + Parameter = 129, + Decorator = 130, + PropertySignature = 131, + PropertyDeclaration = 132, + MethodSignature = 133, + MethodDeclaration = 134, + Constructor = 135, + GetAccessor = 136, + SetAccessor = 137, + CallSignature = 138, + ConstructSignature = 139, + IndexSignature = 140, + TypeReference = 141, + FunctionType = 142, + ConstructorType = 143, + TypeQuery = 144, + TypeLiteral = 145, + ArrayType = 146, + TupleType = 147, + UnionType = 148, + ParenthesizedType = 149, + ObjectBindingPattern = 150, + ArrayBindingPattern = 151, + BindingElement = 152, + ArrayLiteralExpression = 153, + ObjectLiteralExpression = 154, + PropertyAccessExpression = 155, + ElementAccessExpression = 156, + CallExpression = 157, + NewExpression = 158, + TaggedTemplateExpression = 159, + TypeAssertionExpression = 160, + ParenthesizedExpression = 161, + FunctionExpression = 162, + ArrowFunction = 163, + DeleteExpression = 164, + TypeOfExpression = 165, + VoidExpression = 166, + PrefixUnaryExpression = 167, + PostfixUnaryExpression = 168, + BinaryExpression = 169, + ConditionalExpression = 170, + TemplateExpression = 171, + YieldExpression = 172, + SpreadElementExpression = 173, + OmittedExpression = 174, + TemplateSpan = 175, + Block = 176, + VariableStatement = 177, + EmptyStatement = 178, + ExpressionStatement = 179, + IfStatement = 180, + DoStatement = 181, + WhileStatement = 182, + ForStatement = 183, + ForInStatement = 184, + ForOfStatement = 185, + ContinueStatement = 186, + BreakStatement = 187, + ReturnStatement = 188, + WithStatement = 189, + SwitchStatement = 190, + LabeledStatement = 191, + ThrowStatement = 192, + TryStatement = 193, + DebuggerStatement = 194, + VariableDeclaration = 195, + VariableDeclarationList = 196, + FunctionDeclaration = 197, + ClassDeclaration = 198, + InterfaceDeclaration = 199, + TypeAliasDeclaration = 200, + EnumDeclaration = 201, + ModuleDeclaration = 202, + ModuleBlock = 203, + CaseBlock = 204, + ImportEqualsDeclaration = 205, + ImportDeclaration = 206, + ImportClause = 207, + NamespaceImport = 208, + NamedImports = 209, + ImportSpecifier = 210, + ExportAssignment = 211, + ExportDeclaration = 212, + NamedExports = 213, + ExportSpecifier = 214, + MissingDeclaration = 215, + ExternalModuleReference = 216, + CaseClause = 217, + DefaultClause = 218, + HeritageClause = 219, + CatchClause = 220, + PropertyAssignment = 221, + ShorthandPropertyAssignment = 222, + EnumMember = 223, + SourceFile = 224, + SyntaxList = 225, + Count = 226, + FirstAssignment = 53, + LastAssignment = 64, + FirstReservedWord = 66, + LastReservedWord = 101, + FirstKeyword = 66, + LastKeyword = 125, + FirstFutureReservedWord = 103, + LastFutureReservedWord = 111, + FirstTypeNode = 141, + LastTypeNode = 149, FirstPunctuation = 14, - LastPunctuation = 63, + LastPunctuation = 64, FirstToken = 0, - LastToken = 124, + LastToken = 125, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -267,8 +270,8 @@ declare module ts { FirstTemplateToken = 10, LastTemplateToken = 13, FirstBinaryOperator = 24, - LastBinaryOperator = 63, - FirstNode = 125, + LastBinaryOperator = 64, + FirstNode = 126, } const enum NodeFlags { Export = 1, @@ -284,6 +287,7 @@ declare module ts { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -293,10 +297,11 @@ declare module ts { DisallowIn = 2, Yield = 4, GeneratorParameter = 8, - ThisNodeHasError = 16, - ParserGeneratedFlags = 31, - ThisNodeOrAnySubNodesHasError = 32, - HasAggregatedChildData = 64, + Decorator = 16, + ThisNodeHasError = 32, + ParserGeneratedFlags = 63, + ThisNodeOrAnySubNodesHasError = 64, + HasAggregatedChildData = 128, } const enum RelationComparisonResult { Succeeded = 1, @@ -307,6 +312,7 @@ declare module ts { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -337,6 +343,9 @@ declare module ts { interface ComputedPropertyName extends Node { expression: Expression; } + interface Decorator extends Node { + expression: LeftHandSideExpression; + } interface TypeParameterDeclaration extends Declaration { name: Identifier; constraint?: TypeNode; @@ -516,6 +525,9 @@ declare module ts { name?: Identifier; body: Block | Expression; } + interface ArrowFunction extends Expression, FunctionLikeDeclaration { + equalsGreaterThanToken: Node; + } interface LiteralExpression extends PrimaryExpression { text: string; isUnterminated?: boolean; @@ -725,7 +737,8 @@ declare module ts { type ExportSpecifier = ImportOrExportSpecifier; interface ExportAssignment extends Declaration, ModuleElement { isExportEquals?: boolean; - expression: Expression; + expression?: Expression; + type?: TypeNode; } interface FileReference extends TextRange { fileName: string; @@ -760,14 +773,14 @@ declare module ts { interface Program extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; /** - * Emits the javascript and declaration files. If targetSourceFile is not specified, then - * the javascript and declaration files will be produced for all the files in this program. - * If targetSourceFile is specified, then only the javascript and declaration for that + * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then + * the JavaScript and declaration files will be produced for all the files in this program. + * If targetSourceFile is specified, then only the JavaScript and declaration for that * specific file will be generated. * * If writeFile is not specified then the writeFile callback from the compiler host will be - * used for writing the javascript and declaration files. Otherwise, the writeFile parameter - * will be invoked when writing the javascript and declaration files. + * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter + * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; @@ -886,9 +899,10 @@ declare module ts { NotAccessible = 1, CannotBeNamed = 2, } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; interface SymbolVisibilityResult { accessibility: SymbolAccessibility; - aliasesToMakeVisible?: ImportEqualsDeclaration[]; + aliasesToMakeVisible?: AnyImportSyntax[]; errorSymbolName?: string; errorNode?: Node; } @@ -896,20 +910,22 @@ declare module ts { errorModuleName?: string; } interface EmitResolver { - getGeneratedNameForNode(node: Node): string; - getExpressionNameSubstitution(node: Identifier): string; - hasExportDefaultValue(node: SourceFile): boolean; - isReferencedAliasDeclaration(node: Node): boolean; + hasGlobalName(name: string): boolean; + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isUnknownIdentifier(location: Node, name: string): boolean; + resolvesToSomeValue(location: Node, name: string): boolean; getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { @@ -1016,6 +1032,7 @@ declare module ts { ContextChecked = 64, EnumValuesComputed = 128, BlockScopedBindingInLoop = 256, + EmitDecorate = 512, } interface NodeLinks { resolvedType?: Type; @@ -1135,17 +1152,6 @@ declare module ts { interface TypeMapper { (t: Type): Type; } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - } - interface InferenceContext { - typeParameters: TypeParameter[]; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - failedTypeParameterIndex?: number; - } interface DiagnosticMessage { key: string; category: DiagnosticCategory; @@ -1442,7 +1448,8 @@ declare module ts { declare module ts { /** The version of the TypeScript compiler release */ let version: string; - function createCompilerHost(options: CompilerOptions): CompilerHost; + function findConfigFile(searchPath: string): string; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; @@ -1556,6 +1563,7 @@ declare module ts { getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + findReferences(fileName: string, position: number): ReferencedSymbol[]; getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getOutliningSpans(fileName: string): OutliningSpan[]; @@ -1642,6 +1650,10 @@ declare module ts { containerKind: string; containerName: string; } + interface ReferencedSymbol { + definition: DefinitionInfo; + references: ReferenceEntry[]; + } enum SymbolDisplayPartKind { aliasName = 0, className = 1, diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 9e939631006..2a8a4725b29 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -68,192 +68,195 @@ var ts; SyntaxKind[SyntaxKind["BarBarToken"] = 49] = "BarBarToken"; SyntaxKind[SyntaxKind["QuestionToken"] = 50] = "QuestionToken"; SyntaxKind[SyntaxKind["ColonToken"] = 51] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 52] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 53] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 54] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 55] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 56] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 57] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 58] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 59] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 60] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 61] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 62] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 63] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 64] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 65] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 66] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 67] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 68] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 69] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 70] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 71] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 72] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 73] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 74] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 75] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 76] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 77] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 78] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 79] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 80] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 81] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 82] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 83] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 84] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 85] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 86] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 87] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 88] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 89] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 90] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 91] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 92] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 93] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 94] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 95] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 96] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 97] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 98] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 99] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 100] = "WithKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 101] = "AsKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 102] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 103] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 104] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 105] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 106] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 107] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 108] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 109] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 110] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 111] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 112] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 113] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 114] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 115] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 116] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 117] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 118] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 119] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 120] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 121] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 122] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 123] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 124] = "OfKeyword"; - SyntaxKind[SyntaxKind["QualifiedName"] = 125] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 126] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 127] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 128] = "Parameter"; - SyntaxKind[SyntaxKind["PropertySignature"] = 129] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 130] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 131] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 132] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 133] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 134] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 135] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 136] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 137] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 138] = "IndexSignature"; - SyntaxKind[SyntaxKind["TypeReference"] = 139] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 140] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 141] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 142] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 143] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 144] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 145] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 146] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 147] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 148] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 149] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 150] = "BindingElement"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 151] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 152] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 153] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 154] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 155] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 156] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 157] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 158] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 159] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 160] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 161] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 162] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 163] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 164] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 165] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 166] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 167] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 168] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 169] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 170] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 171] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 172] = "OmittedExpression"; - SyntaxKind[SyntaxKind["TemplateSpan"] = 173] = "TemplateSpan"; - SyntaxKind[SyntaxKind["Block"] = 174] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 175] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 176] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 177] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 178] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 179] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 180] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 181] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 182] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 183] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 184] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 185] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 186] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 187] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 188] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 189] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 190] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 191] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 192] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 193] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 194] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 195] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 196] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 197] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 198] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 199] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 200] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 201] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 202] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 203] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 204] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 205] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 206] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 207] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 208] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 209] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 210] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 211] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 212] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 213] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["CaseClause"] = 214] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 215] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 216] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 217] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 218] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 219] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 220] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 221] = "SourceFile"; - SyntaxKind[SyntaxKind["SyntaxList"] = 222] = "SyntaxList"; - SyntaxKind[SyntaxKind["Count"] = 223] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = 52] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 63] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 65] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 100] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 65] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 124] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 139] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 147] = "LastTypeNode"; + SyntaxKind[SyntaxKind["AtToken"] = 52] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 53] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 54] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 55] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 56] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 57] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 58] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 59] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 60] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 62] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 63] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 64] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 65] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 66] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 67] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 68] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 69] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 70] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 71] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 72] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 73] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 74] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 75] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 76] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 77] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 78] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 79] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 80] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 81] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 82] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 83] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 84] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 85] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 86] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 87] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 88] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 89] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 90] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 91] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 92] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 93] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 94] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 95] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 96] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 97] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 98] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 99] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 100] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 101] = "WithKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 102] = "AsKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 112] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 113] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 117] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 118] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 119] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 120] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 121] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 122] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 123] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 124] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 125] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 126] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 127] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 128] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 129] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 130] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 131] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 132] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 133] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 134] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 135] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 136] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 137] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 138] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 139] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 140] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypeReference"] = 141] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 142] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 143] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 144] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 145] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 146] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 147] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 148] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 149] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 150] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 151] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 152] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 153] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 154] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 155] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 156] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 157] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 158] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 159] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 160] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 161] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 162] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 163] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 164] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 165] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 166] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 167] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 168] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 169] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 170] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 171] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 172] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 173] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 174] = "OmittedExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 175] = "TemplateSpan"; + SyntaxKind[SyntaxKind["Block"] = 176] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 177] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 178] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 179] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 180] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 181] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 182] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 183] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 184] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 185] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 186] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 187] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 188] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 189] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 190] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 191] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 192] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 193] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 194] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 195] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 196] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 197] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 198] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 199] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 200] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 201] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 202] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 203] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 204] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 205] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 206] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 207] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 208] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 209] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 210] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 211] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 212] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 213] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 214] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 215] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 216] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["CaseClause"] = 217] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 218] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 219] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 220] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 221] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 222] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 223] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 224] = "SourceFile"; + SyntaxKind[SyntaxKind["SyntaxList"] = 225] = "SyntaxList"; + SyntaxKind[SyntaxKind["Count"] = 226] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 125] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 141] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 149] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 63] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 124] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 125] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -261,8 +264,8 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 63] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 125] = "FirstNode"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 126] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -279,6 +282,7 @@ var ts; NodeFlags[NodeFlags["Let"] = 4096] = "Let"; NodeFlags[NodeFlags["Const"] = 8192] = "Const"; NodeFlags[NodeFlags["OctalLiteral"] = 16384] = "OctalLiteral"; + NodeFlags[NodeFlags["ExportContext"] = 32768] = "ExportContext"; NodeFlags[NodeFlags["Modifier"] = 499] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 12288] = "BlockScoped"; @@ -289,10 +293,11 @@ var ts; ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; ParserContextFlags[ParserContextFlags["Yield"] = 4] = "Yield"; ParserContextFlags[ParserContextFlags["GeneratorParameter"] = 8] = "GeneratorParameter"; - ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; - ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 32] = "ThisNodeOrAnySubNodesHasError"; - ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 64] = "HasAggregatedChildData"; + ParserContextFlags[ParserContextFlags["Decorator"] = 16] = "Decorator"; + ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 32] = "ThisNodeHasError"; + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 63] = "ParserGeneratedFlags"; + ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; + ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); var ParserContextFlags = ts.ParserContextFlags; (function (RelationComparisonResult) { @@ -408,6 +413,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 64] = "ContextChecked"; NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 128] = "EnumValuesComputed"; NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 256] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 512] = "EmitDecorate"; })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var NodeCheckFlags = ts.NodeCheckFlags; (function (TypeFlags) { @@ -597,6 +603,7 @@ var ts; })(ts.CharacterCodes || (ts.CharacterCodes = {})); var CharacterCodes = ts.CharacterCodes; })(ts || (ts = {})); +/// var ts; (function (ts) { (function (Ternary) { @@ -664,9 +671,9 @@ var ts; if (array) { result = []; for (var _i = 0, _n = array.length; _i < _n; _i++) { - var _item = array[_i]; - if (f(_item)) { - result.push(_item); + var item_1 = array[_i]; + if (f(item_1)) { + result.push(item_1); } } } @@ -698,9 +705,9 @@ var ts; if (array) { result = []; for (var _i = 0, _n = array.length; _i < _n; _i++) { - var _item = array[_i]; - if (!contains(result, _item)) { - result.push(_item); + var item_2 = array[_i]; + if (!contains(result, item_2)) { + result.push(item_2); } } } @@ -717,9 +724,11 @@ var ts; } ts.sum = sum; function addRange(to, from) { - for (var _i = 0, _n = from.length; _i < _n; _i++) { - var v = from[_i]; - to.push(v); + if (to && from) { + for (var _i = 0, _n = from.length; _i < _n; _i++) { + var v = from[_i]; + to.push(v); + } } } ts.addRange = addRange; @@ -749,6 +758,35 @@ var ts; return ~low; } ts.binarySearch = binarySearch; + function reduceLeft(array, f, initial) { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + function reduceRight(array, f, initial) { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + ts.reduceRight = reduceRight; var hasOwnProperty = Object.prototype.hasOwnProperty; function hasProperty(map, key) { return hasOwnProperty.call(map, key); @@ -780,9 +818,9 @@ var ts; for (var id in first) { result[id] = first[id]; } - for (var _id in second) { - if (!hasProperty(result, _id)) { - result[_id] = second[_id]; + for (var id in second) { + if (!hasProperty(result, id)) { + result[id] = second[id]; } } return result; @@ -810,14 +848,6 @@ var ts; return hasProperty(map, key) ? map[key] : undefined; } ts.lookUp = lookUp; - function mapToArray(map) { - var result = []; - for (var id in map) { - result.push(map[id]); - } - return result; - } - ts.mapToArray = mapToArray; function copyMap(source, target) { for (var p in source) { target[p] = source[p]; @@ -1043,6 +1073,9 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { + // Get root length of http://www.website.com/folder1/foler2/ + // In this example the root is: http://www.website.com/ + // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { @@ -1212,6 +1245,7 @@ var ts; Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { ts.sys = (function () { @@ -1286,9 +1320,9 @@ var ts; var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); for (var _i = 0, _n = files.length; _i < _n; _i++) { - var _name = files[_i]; - if (!extension || ts.fileExtensionIs(_name, extension)) { - result.push(ts.combinePaths(path, _name)); + var name_1 = files[_i]; + if (!extension || ts.fileExtensionIs(name_1, extension)) { + result.push(ts.combinePaths(path, name_1)); } } var subfolders = getNames(folder.subfolders); @@ -1393,8 +1427,8 @@ var ts; } } for (var _a = 0, _b = directories.length; _a < _b; _a++) { - var _current = directories[_a]; - visitDirectory(_current); + var current = directories[_a]; + visitDirectory(current); } } } @@ -1463,559 +1497,573 @@ var ts; } })(); })(ts || (ts = {})); +/// var ts; (function (ts) { ts.Diagnostics = { - Unterminated_string_literal: { code: 1002, category: 1, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: 1, key: "Identifier expected." }, - _0_expected: { code: 1005, category: 1, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: 1, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: 1, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: 1, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: 1, key: "Unexpected token." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: 1, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: 1, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: 1, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: 1, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: 1, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: 1, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: 1, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: 1, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: 1, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: 1, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: 1, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: 1, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: 1, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: 1, key: "A class declaration can only have one 'implements' clause." }, - Accessibility_modifier_already_seen: { code: 1028, category: 1, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: 1, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: 1, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: 1, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: 1, key: "An interface declaration cannot have an 'implements' clause." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: 1, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: 1, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: 1, key: "Statements are not allowed in ambient contexts." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: 1, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: 1, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: 1, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: 1, key: "A 'declare' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: 1, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: 1, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: 1, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: 1, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: 1, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: 1, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: 1, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: 1, key: "A 'get' accessor cannot have parameters." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: 1, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - Enum_member_must_have_initializer: { code: 1061, category: 1, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: 1, key: "An export assignment cannot be used in an internal module." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: 1, key: "Ambient enum elements can only have integer literal initializers." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: 1, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: 1, key: "A 'declare' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: 1, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: 1, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: 1, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: 1, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: 1, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: 1, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: 1, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: 1, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: 1, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: 1, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: 1, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: 1, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: 1, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: 1, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: 1, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: 1, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: 1, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: 1, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: 1, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: 1, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: 1, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: 1, key: "Expression expected." }, - Type_expected: { code: 1110, category: 1, key: "Type expected." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: 1, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: 1, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: 1, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: 1, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: 1, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: 1, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: 1, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: 1, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: 1, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: 1, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: 1, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: 1, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: 1, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: 1, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: 1, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: 1, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: 1, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: 1, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: 1, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: 1, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: 1, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: 1, key: "Type reference expected." }, - Variable_declaration_expected: { code: 1134, category: 1, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: 1, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: 1, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: 1, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: 1, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: 1, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: 1, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: 1, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: 1, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: 1, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: 1, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: 1, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: 1, key: "Import declarations in an internal module cannot reference an external module." }, - Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: 1, key: "Cannot compile external modules unless the '--module' flag is provided." }, - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: 1, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: 1, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: 1, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: 1, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: 1, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_must_be_initialized: { code: 1155, category: 1, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1, key: "'let' declarations can only be declared inside a block." }, - Unterminated_template_literal: { code: 1160, category: 1, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: 1, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: 1, key: "An object member cannot be declared optional." }, - yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1, key: "'yield' expression must be contained_within a generator declaration." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: 1, key: "Computed property names are not allowed in enums." }, - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: 1, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: 1, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: 1, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: 1, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: 1, key: "A computed property name in an interface must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: 1, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: 1, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: 1, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: 1, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: 1, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: 1, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: 1, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: 1, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: 1, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: 1, key: "Unexpected token. '{' expected." }, - Property_destructuring_pattern_expected: { code: 1180, category: 1, key: "Property destructuring pattern expected." }, - Array_element_destructuring_pattern_expected: { code: 1181, category: 1, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: 1, key: "A destructuring declaration must have an initializer." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: 1, key: "Destructuring declarations are not allowed in ambient contexts." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: 1, key: "An implementation cannot be declared in ambient contexts." }, - Modifiers_cannot_appear_here: { code: 1184, category: 1, key: "Modifiers cannot appear here." }, - Merge_conflict_marker_encountered: { code: 1185, category: 1, key: "Merge conflict marker encountered." }, - A_rest_element_cannot_have_an_initializer: { code: 1186, category: 1, key: "A rest element cannot have an initializer." }, - A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: 1, key: "A parameter property may not be a binding pattern." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: 1, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: 1, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: 1, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, - An_import_declaration_cannot_have_modifiers: { code: 1191, category: 1, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export_or_export_assignment: { code: 1192, category: 1, key: "External module '{0}' has no default export or export assignment." }, - An_export_declaration_cannot_have_modifiers: { code: 1193, category: 1, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: 1, key: "Export declarations are not permitted in an internal module." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: 1, key: "Catch clause variable name must be an identifier." }, - Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: 1, key: "Catch clause variable cannot have a type annotation." }, - Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: 1, key: "Catch clause variable cannot have an initializer." }, - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: 1, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, - Unterminated_Unicode_escape_sequence: { code: 1199, category: 1, key: "Unterminated Unicode escape sequence." }, - Duplicate_identifier_0: { code: 2300, category: 1, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: 1, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: 1, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: 1, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_an_external_module: { code: 2306, category: 1, key: "File '{0}' is not an external module." }, - Cannot_find_external_module_0: { code: 2307, category: 1, key: "Cannot find external module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: 1, key: "A module cannot have more than one export assignment." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: 1, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: 1, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: 1, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: 1, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: 1, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: 1, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: 1, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: 1, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: 1, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: 1, key: "Cannot find global type '{0}'." }, - Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: 1, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: 1, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: 1, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: 1, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: 1, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: 1, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: 1, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: 1, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: 1, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: 1, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: 1, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_body: { code: 2331, category: 1, key: "'this' cannot be referenced in a module body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: 1, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: 1, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: 1, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: 1, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: 1, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: 1, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: 1, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: 1, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: 1, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: 1, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: 1, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: 1, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: 1, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: 1, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: 1, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: 1, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: 1, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: 1, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: 1, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: 1, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: 1, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: 1, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: 1, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: 1, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: 1, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: 1, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: 1, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: 1, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: 1, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: 1, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: 1, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: 1, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: 1, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: 1, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: 1, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: 1, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: 1, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: 1, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: 1, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: 1, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: 1, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: 1, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: 1, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: 1, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: 1, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: 1, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: 1, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: 1, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: 1, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: 1, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: 1, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: 1, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: 1, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: 1, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: 1, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: 1, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: 1, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: 1, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: 1, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: 1, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: 1, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: 1, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: 1, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: 1, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: 1, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: 1, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: 1, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: 1, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: 1, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: 1, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: 1, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: 1, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: 1, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: 1, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: 1, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: 1, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: 1, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: 1, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: 1, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: 1, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: 1, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: 1, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: 1, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: 1, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: 1, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: 1, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: 1, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: 1, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: 1, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: 1, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: 1, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: 1, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, - A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: 1, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: 1, key: "Ambient external modules cannot be nested in other modules." }, - Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: 1, key: "Ambient external module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: 1, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: 1, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: 1, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: 1, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: 1, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: 1, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: 1, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: 1, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: 1, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: 1, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: 1, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: 1, key: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: 1, key: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: 1, key: "Left-hand side of assignment expression cannot be a constant." }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: 1, key: "Cannot redeclare block-scoped variable '{0}'." }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: 1, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: 1, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: 1, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: 1, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: 1, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: 1, key: "An AMD module cannot have multiple name assignments." }, - Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: 1, key: "Type '{0}' has no property '{1}' and no string index signature." }, - Type_0_has_no_property_1: { code: 2460, category: 1, key: "Type '{0}' has no property '{1}'." }, - Type_0_is_not_an_array_type: { code: 2461, category: 1, key: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: 1, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: 1, key: "A binding pattern parameter cannot be optional in an implementation signature." }, - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: 1, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, - this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: 1, key: "'this' cannot be referenced in a computed property name." }, - super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: 1, key: "'super' cannot be referenced in a computed property name." }, - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: 1, key: "A computed property name cannot reference a type parameter from its containing type." }, - Cannot_find_global_value_0: { code: 2468, category: 1, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: 1, key: "The '{0}' operator cannot be applied to type 'symbol'." }, - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: 1, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: 1, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: 1, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: 1, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: 1, key: "In 'const' enum declarations member initializer must be constant expression." }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: 1, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: 1, key: "A const enum member can only be accessed using a string literal." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: 1, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: 1, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: 1, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: 1, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: 1, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: 1, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, - Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: 1, key: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: 1, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: 1, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: 1, key: "Invalid left-hand side in 'for...of' statement." }, - The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: 1, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, - The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: 1, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: 1, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: 1, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: 1, key: "Cannot redeclare identifier '{0}' in catch clause" }, - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: 1, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: 1, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2461, category: 1, key: "Type '{0}' is not an array type or a string type." }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: 1, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: 1, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: 1, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: 1, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: 1, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: 1, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: 1, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: 1, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: 1, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: 1, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: 1, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: 1, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: 1, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: 1, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: 1, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: 1, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: 1, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: 1, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: 1, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: 1, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: 1, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: 1, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: 1, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: 1, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: 1, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: 1, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: 1, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: 1, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: 1, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: 1, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: 1, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: 1, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: 1, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: 1, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: 1, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: 1, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: 1, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: 1, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: 1, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: 1, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: 1, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: 1, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: 1, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: 1, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: 1, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: 1, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: 1, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: 1, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: 1, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: 1, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: 1, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: 1, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: 1, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: 1, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: 1, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: 1, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: 1, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: 1, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: 1, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: 1, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: 1, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: 1, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: 1, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: 1, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: 1, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: 1, key: "Unsupported file encoding." }, - Unknown_compiler_option_0: { code: 5023, category: 1, key: "Unknown compiler option '{0}'." }, - Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: 1, key: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: 1, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: 1, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: 1, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: 1, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: 1, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: 1, key: "Option 'project' cannot be mixed with source files on a command line." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: 2, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: 2, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: 2, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: 2, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: 2, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: 2, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: 2, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: 2, key: "Do not emit outputs if any type checking errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: 2, key: "Do not emit comments to output." }, - Do_not_emit_outputs: { code: 6010, category: 2, key: "Do not emit outputs." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: 2, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: 2, key: "Specify module code generation: 'commonjs' or 'amd'" }, - Print_this_message: { code: 6017, category: 2, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: 2, key: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: 2, key: "Compile the project in the given directory." }, - Syntax_Colon_0: { code: 6023, category: 2, key: "Syntax: {0}" }, - options: { code: 6024, category: 2, key: "options" }, - file: { code: 6025, category: 2, key: "file" }, - Examples_Colon_0: { code: 6026, category: 2, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: 2, key: "Options:" }, - Version_0: { code: 6029, category: 2, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: 2, key: "Insert command line options and files from a file." }, - File_change_detected_Starting_incremental_compilation: { code: 6032, category: 2, key: "File change detected. Starting incremental compilation..." }, - KIND: { code: 6034, category: 2, key: "KIND" }, - FILE: { code: 6035, category: 2, key: "FILE" }, - VERSION: { code: 6036, category: 2, key: "VERSION" }, - LOCATION: { code: 6037, category: 2, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: 2, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: 2, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: 2, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: 1, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: 1, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: 1, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: 1, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: 1, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: 1, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: 1, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: 1, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2, key: "Raise error on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: 1, key: "File '{0}' not found." }, - File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: 2, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: 2, key: "Preserve new-lines when emitting code." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: 1, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: 1, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: 1, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: 1, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: 1, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: 1, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: 1, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: 1, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: 1, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: 1, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: 1, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: 1, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: 1, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, - _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: 1, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: 1, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: 1, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - You_cannot_rename_this_element: { code: 8000, category: 1, key: "You cannot rename this element." }, - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: 1, key: "You cannot rename elements that are defined in the standard TypeScript library." }, - yield_expressions_are_not_currently_supported: { code: 9000, category: 1, key: "'yield' expressions are not currently supported." }, - Generators_are_not_currently_supported: { code: 9001, category: 1, key: "Generators are not currently supported." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: 1, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." } + Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated string literal." }, + Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier expected." }, + _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, + Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing comma not allowed." }, + Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "'*/' expected." }, + Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected token." }, + A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, + Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, + A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, + An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, + An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, + An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, + An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, + An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, + An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, + An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, + A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, + A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: ts.DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, + Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, + _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, + _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, + _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, + An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: ts.DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, + super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, + Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, + Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, + Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, + A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, + A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, + A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, + A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, + A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, + A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, + An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." }, + Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, + A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, + _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, + _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, + Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, + Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, + An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, + A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, + An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, + _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, + Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, + Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, + with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, + delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, + Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, + A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, + Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression expected." }, + Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type expected." }, + A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, + An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, + Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, + A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, + Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, + Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit expected." }, + Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, + Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected end of text." }, + Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid character." }, + Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration or statement expected." }, + Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement expected." }, + case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, + Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, + Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, + Type_reference_expected: { code: 1133, category: ts.DiagnosticCategory.Error, key: "Type reference expected." }, + Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, + Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, + Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, + Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression or comma expected." }, + Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter declaration expected." }, + Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type parameter declaration expected." }, + Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type argument expected." }, + String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String literal expected." }, + Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line break not permitted here." }, + or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, + Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, + Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." }, + Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." }, + File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, + let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: ts.DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, + const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: ts.DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, + const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, + let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, + Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated template literal." }, + Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, + yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: ts.DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, + A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: ts.DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, + A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, + Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, + Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, + A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, + A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, + An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, + External_module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "External module '{0}' has no default export." }, + An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, + Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, + Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, + Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, + Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, + Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, + A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: ts.DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, + Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, + Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, + Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, + Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, + Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, + Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, + File_0_is_not_an_external_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not an external module." }, + Cannot_find_external_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find external module '{0}'." }, + A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, + Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, + A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, + An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An interface may only extend a class or another interface." }, + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, + Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic type '{0}' requires {1} type argument(s)." }, + Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not generic." }, + Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." }, + Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." }, + Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot find global type '{0}'." }, + Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, + Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, + Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, + Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, + Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, + Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, + Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, + Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, + Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, + Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, + Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, + this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, + this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, + this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, + this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, + super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, + super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, + Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, + Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, + Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot invoke an expression whose type lacks a call signature." }, + Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, + Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, + Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, + Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, + A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, + A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A parameter initializer is only allowed in a function or constructor implementation." }, + Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' cannot be referenced in its initializer." }, + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, + Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate string index signature." }, + Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate number index signature." }, + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, + Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, + A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, + get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, + A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, + Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, + Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, + Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, + Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function overload must be static." }, + Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function overload must not be static." }, + Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." }, + Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor implementation is missing." }, + Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." }, + Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, + Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, + Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, + Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." }, + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, + Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, + All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, + Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, + Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, + Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, + Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, + Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, + Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, + Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly implements interface '{1}'." }, + A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A class may only implement another class or interface." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, + Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface name cannot be '{0}'" }, + All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." }, + Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, + Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, + A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, + A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient external modules cannot be nested in other modules." }, + Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, + Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, + Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, + Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, + Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." }, + Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." }, + An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." }, + The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, + Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, + Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, + An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, + A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, + this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." }, + super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, + Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, + The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, + Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, + A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, + Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, + Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, + The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, + The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, + Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, + Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, + The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." }, + External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, + Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, + Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, + Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, + Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, + Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, + Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, + The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, + Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, + Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, + Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, + Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, + Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, + Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, + Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, + Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch input files." }, + Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, + Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any type checking errors were reported." }, + Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, + Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, + Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, + Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, + Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, + Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, + Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax: {0}" }, + options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options" }, + file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file" }, + Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples: {0}" }, + Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options:" }, + Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version {0}" }, + Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, + File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, + KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND" }, + FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE" }, + VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION" }, + LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION" }, + DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY" }, + Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, + Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, + Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, + Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, + Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, + Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, + Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, + Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, + Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, + File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File '{0}' not found." }, + File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, + Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, + Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, + Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, + Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, + Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index signature of object type implicitly has an 'any' type." }, + Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, + Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, + _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, + _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, + You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, + yield_expressions_are_not_currently_supported: { code: 9000, category: ts.DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, + Generators_are_not_currently_supported: { code: 9001, category: ts.DiagnosticCategory.Error, key: "Generators are not currently supported." } }; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { var textToToken = { - "any": 111, - "as": 101, - "boolean": 112, - "break": 65, - "case": 66, - "catch": 67, - "class": 68, - "continue": 70, - "const": 69, - "constructor": 113, - "debugger": 71, - "declare": 114, - "default": 72, - "delete": 73, - "do": 74, - "else": 75, - "enum": 76, - "export": 77, - "extends": 78, - "false": 79, - "finally": 80, - "for": 81, - "from": 123, - "function": 82, - "get": 115, - "if": 83, - "implements": 102, - "import": 84, - "in": 85, - "instanceof": 86, - "interface": 103, - "let": 104, - "module": 116, - "new": 87, - "null": 88, - "number": 118, - "package": 105, - "private": 106, - "protected": 107, - "public": 108, - "require": 117, - "return": 89, - "set": 119, - "static": 109, - "string": 120, - "super": 90, - "switch": 91, - "symbol": 121, - "this": 92, - "throw": 93, - "true": 94, - "try": 95, - "type": 122, - "typeof": 96, - "var": 97, - "void": 98, - "while": 99, - "with": 100, - "yield": 110, - "of": 124, + "any": 112, + "as": 102, + "boolean": 113, + "break": 66, + "case": 67, + "catch": 68, + "class": 69, + "continue": 71, + "const": 70, + "constructor": 114, + "debugger": 72, + "declare": 115, + "default": 73, + "delete": 74, + "do": 75, + "else": 76, + "enum": 77, + "export": 78, + "extends": 79, + "false": 80, + "finally": 81, + "for": 82, + "from": 124, + "function": 83, + "get": 116, + "if": 84, + "implements": 103, + "import": 85, + "in": 86, + "instanceof": 87, + "interface": 104, + "let": 105, + "module": 117, + "new": 88, + "null": 89, + "number": 119, + "package": 106, + "private": 107, + "protected": 108, + "public": 109, + "require": 118, + "return": 90, + "set": 120, + "static": 110, + "string": 121, + "super": 91, + "switch": 92, + "symbol": 122, + "this": 93, + "throw": 94, + "true": 95, + "try": 96, + "type": 123, + "typeof": 97, + "var": 98, + "void": 99, + "while": 100, + "with": 101, + "yield": 111, + "of": 125, "{": 14, "}": 15, "(": 16, @@ -2054,18 +2102,19 @@ var ts; "||": 49, "?": 50, ":": 51, - "=": 52, - "+=": 53, - "-=": 54, - "*=": 55, - "/=": 56, - "%=": 57, - "<<=": 58, - ">>=": 59, - ">>>=": 60, - "&=": 61, - "|=": 62, - "^=": 63 + "=": 53, + "+=": 54, + "-=": 55, + "*=": 56, + "/=": 57, + "%=": 58, + "<<=": 59, + ">>=": 60, + ">>>=": 61, + "&=": 62, + "|=": 63, + "^=": 64, + "@": 52 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -2106,9 +2155,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var _name in source) { - if (source.hasOwnProperty(_name)) { - result[source[_name]] = _name; + for (var name_2 in source) { + if (source.hasOwnProperty(name_2)) { + result[source[name_2]] = name_2; } } return result; @@ -2118,6 +2167,10 @@ var ts; return tokenStrings[t]; } ts.tokenToString = tokenToString; + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; function computeLineStarts(text) { var result = new Array(); var pos = 0; @@ -2175,13 +2228,35 @@ var ts; ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { - return ch === 32 || ch === 9 || ch === 11 || ch === 12 || - ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 || - ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279; + return ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; } ts.isWhiteSpace = isWhiteSpace; function isLineBreak(ch) { - return ch === 10 || ch === 13 || ch === 8232 || ch === 8233 || ch === 133; + // ES5 7.3: + // The ECMAScript line terminator characters are listed in Table 3. + // Table 3 � Line Terminator Characters + // Code Unit Value Name Formal Name + // \u000A Line Feed + // \u000D Carriage Return + // \u2028 Line separator + // \u2029 Paragraph separator + // Only the characters in Table 3 are treated as line terminators. Other new line or line + // breaking characters are treated as white space but not as line terminators. + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; } ts.isLineBreak = isLineBreak; function isDigit(ch) { @@ -2284,8 +2359,8 @@ var ts; else { ts.Debug.assert(ch === 61); while (pos < len) { - var _ch = text.charCodeAt(pos); - if (_ch === 62 && isConflictMarkerTrivia(text, pos)) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -2300,8 +2375,9 @@ var ts; var ch = text.charCodeAt(pos); switch (ch) { case 13: - if (text.charCodeAt(pos + 1) === 10) + if (text.charCodeAt(pos + 1) === 10) { pos++; + } case 10: pos++; if (trailing) { @@ -2343,8 +2419,9 @@ var ts; } } if (collecting) { - if (!result) + if (!result) { result = []; + } result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine }); } continue; @@ -2683,14 +2760,14 @@ var ts; return result; } function getIdentifierToken() { - var _len = tokenValue.length; - if (_len >= 2 && _len <= 11) { + var len = tokenValue.length; + if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { return token = textToToken[tokenValue]; } } - return token = 64; + return token = 65; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2769,7 +2846,7 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 37; case 38: @@ -2777,7 +2854,7 @@ var ts; return pos += 2, token = 48; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } return pos++, token = 43; case 40: @@ -2786,7 +2863,7 @@ var ts; return pos++, token = 17; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; + return pos += 2, token = 56; } return pos++, token = 35; case 43: @@ -2794,7 +2871,7 @@ var ts; return pos += 2, token = 38; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 53; + return pos += 2, token = 54; } return pos++, token = 33; case 44: @@ -2804,7 +2881,7 @@ var ts; return pos += 2, token = 39; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 54; + return pos += 2, token = 55; } return pos++, token = 34; case 46: @@ -2836,13 +2913,13 @@ var ts; pos += 2; var commentClosed = false; while (pos < len) { - var _ch = text.charCodeAt(pos); - if (_ch === 42 && text.charCodeAt(pos + 1) === 47) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { pos += 2; commentClosed = true; break; } - if (isLineBreak(_ch)) { + if (isLineBreak(ch_2)) { precedingLineBreak = true; } pos++; @@ -2859,7 +2936,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 36; case 48: @@ -2875,22 +2952,22 @@ var ts; } else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; - var _value = scanBinaryOrOctalDigits(2); - if (_value < 0) { + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); - _value = 0; + value = 0; } - tokenValue = "" + _value; + tokenValue = "" + value; return token = 7; } else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; - var _value_1 = scanBinaryOrOctalDigits(8); - if (_value_1 < 0) { + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); - _value_1 = 0; + value = 0; } - tokenValue = "" + _value_1; + tokenValue = "" + value; return token = 7; } if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { @@ -2924,7 +3001,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 58; + return pos += 3, token = 59; } return pos += 2, token = 40; } @@ -2951,7 +3028,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 32; } - return pos++, token = 52; + return pos++, token = 53; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2971,7 +3048,7 @@ var ts; return pos++, token = 19; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } return pos++, token = 45; case 123: @@ -2981,13 +3058,15 @@ var ts; return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } return pos++, token = 44; case 125: return pos++, token = 15; case 126: return pos++, token = 47; + case 64: + return pos++, token = 52; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3027,12 +3106,12 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } return pos++, token = 41; } @@ -3043,7 +3122,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 36 || token === 56) { + if (token === 36 || token === 57) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3137,8 +3216,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 64 || token > 100; }, - isReservedWord: function () { return token >= 65 && token <= 100; }, + isIdentifier: function () { return token === 65 || token > 101; }, + isReservedWord: function () { return token >= 66 && token <= 101; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3152,6 +3231,515 @@ var ts; } ts.createScanner = createScanner; })(ts || (ts = {})); +/// +var ts; +(function (ts) { + ts.bindTime = 0; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; + function getModuleInstanceState(node) { + if (node.kind === 199 || node.kind === 200) { + return 0; + } + else if (ts.isConstEnumDeclaration(node)) { + return 2; + } + else if ((node.kind === 206 || node.kind === 205) && !(node.flags & 1)) { + return 0; + } + else if (node.kind === 203) { + var state = 0; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0: + return false; + case 2: + state = 2; + return false; + case 1: + state = 1; + return true; + } + }); + return state; + } + else if (node.kind === 202) { + return getModuleInstanceState(node.body); + } + else { + return 1; + } + } + ts.getModuleInstanceState = getModuleInstanceState; + function bindSourceFile(file) { + var start = new Date().getTime(); + bindSourceFileWorker(file); + ts.bindTime += new Date().getTime() - start; + } + ts.bindSourceFile = bindSourceFile; + function bindSourceFileWorker(file) { + var parent; + var container; + var blockScopeContainer; + var lastContainer; + var symbolCount = 0; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + file.locals = {}; + container = file; + setBlockScopeContainer(file, false); + bind(file); + file.symbolCount = symbolCount; + } + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function setBlockScopeContainer(node, cleanLocals) { + blockScopeContainer = node; + if (cleanLocals) { + blockScopeContainer.locals = undefined; + } + } + function addDeclarationToSymbol(symbol, node, symbolKind) { + symbol.flags |= symbolKind; + if (!symbol.declarations) + symbol.declarations = []; + symbol.declarations.push(node); + if (symbolKind & 1952 && !symbol.exports) + symbol.exports = {}; + if (symbolKind & 6240 && !symbol.members) + symbol.members = {}; + node.symbol = symbol; + if (symbolKind & 107455 && !symbol.valueDeclaration) + symbol.valueDeclaration = node; + } + function getDeclarationName(node) { + if (node.name) { + if (node.kind === 202 && node.name.kind === 8) { + return '"' + node.name.text + '"'; + } + if (node.name.kind === 127) { + var nameExpression = node.name.expression; + ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); + return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); + } + return node.name.text; + } + switch (node.kind) { + case 143: + case 135: + return "__constructor"; + case 142: + case 138: + return "__call"; + case 139: + return "__new"; + case 140: + return "__index"; + case 212: + return "__export"; + case 211: + return node.isExportEquals ? "export=" : "default"; + case 197: + case 198: + return node.flags & 256 ? "default" : undefined; + } + } + function getDisplayName(node) { + return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); + } + function declareSymbol(symbols, parent, node, includes, excludes) { + ts.Debug.assert(!ts.hasDynamicName(node)); + var name = node.flags & 256 && parent ? "default" : getDeclarationName(node); + var symbol; + if (name !== undefined) { + symbol = ts.hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); + if (symbol.flags & excludes) { + if (node.name) { + node.name.parent = node; + } + var message = symbol.flags & 2 + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + symbol = createSymbol(0, name); + } + } + else { + symbol = createSymbol(0, "__missing"); + } + addDeclarationToSymbol(symbol, node, includes); + symbol.parent = parent; + if (node.kind === 198 && symbol.exports) { + var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); + if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; + } + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; + } + return symbol; + } + function declareModuleMember(node, symbolKind, symbolExcludes) { + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + if (symbolKind & 8388608) { + if (node.kind === 214 || (node.kind === 205 && hasExportModifier)) { + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + } + else { + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + } + } + else { + if (hasExportModifier || container.flags & 32768) { + var exportKind = (symbolKind & 107455 ? 1048576 : 0) | + (symbolKind & 793056 ? 2097152 : 0) | + (symbolKind & 1536 ? 4194304 : 0); + var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); + local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + node.localSymbol = local; + } + else { + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + } + } + } + function bindChildren(node, symbolKind, isBlockScopeContainer) { + if (symbolKind & 255504) { + node.locals = {}; + } + var saveParent = parent; + var saveContainer = container; + var savedBlockScopeContainer = blockScopeContainer; + parent = node; + if (symbolKind & 262128) { + container = node; + if (lastContainer) { + lastContainer.nextContainer = container; + } + lastContainer = container; + } + if (isBlockScopeContainer) { + setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 224); + } + ts.forEachChild(node, bind); + container = saveContainer; + parent = saveParent; + blockScopeContainer = savedBlockScopeContainer; + } + function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { + switch (container.kind) { + case 202: + declareModuleMember(node, symbolKind, symbolExcludes); + break; + case 224: + if (ts.isExternalModule(container)) { + declareModuleMember(node, symbolKind, symbolExcludes); + break; + } + case 142: + case 143: + case 138: + case 139: + case 140: + case 134: + case 133: + case 135: + case 136: + case 137: + case 197: + case 162: + case 163: + declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + break; + case 198: + if (node.flags & 128) { + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + break; + } + case 145: + case 154: + case 199: + declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); + break; + case 201: + declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + break; + } + bindChildren(node, symbolKind, isBlockScopeContainer); + } + function isAmbientContext(node) { + while (node) { + if (node.flags & 2) + return true; + node = node.parent; + } + return false; + } + function hasExportDeclarations(node) { + var body = node.kind === 224 ? node : node.body; + if (body.kind === 224 || body.kind === 203) { + for (var _i = 0, _a = body.statements, _n = _a.length; _i < _n; _i++) { + var stat = _a[_i]; + if (stat.kind === 212 || stat.kind === 211) { + return true; + } + } + } + return false; + } + function setExportContextFlag(node) { + if (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 32768; + } + else { + node.flags &= ~32768; + } + } + function bindModuleDeclaration(node) { + setExportContextFlag(node); + if (node.name.kind === 8) { + bindDeclaration(node, 512, 106639, true); + } + else { + var state = getModuleInstanceState(node); + if (state === 0) { + bindDeclaration(node, 1024, 0, true); + } + else { + bindDeclaration(node, 512, 106639, true); + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } + } + } + } + function bindFunctionOrConstructorType(node) { + // For a given function symbol "<...>(...) => T" we want to generate a symbol identical + // to the one we would get for: { <...>(...): T } + // + // We do that by making an anonymous type literal symbol, and then setting the function + // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable + // from an actual type literal symbol you would have gotten had you used the long form. + var symbol = createSymbol(131072, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072); + bindChildren(node, 131072, false); + var typeLiteralSymbol = createSymbol(2048, "__type"); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048); + typeLiteralSymbol.members = {}; + typeLiteralSymbol.members[node.kind === 142 ? "__call" : "__new"] = symbol; + } + function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { + var symbol = createSymbol(symbolKind, name); + addDeclarationToSymbol(symbol, node, symbolKind); + bindChildren(node, symbolKind, isBlockScopeContainer); + } + function bindCatchVariableDeclaration(node) { + bindChildren(node, 0, true); + } + function bindBlockScopedVariableDeclaration(node) { + switch (blockScopeContainer.kind) { + case 202: + declareModuleMember(node, 2, 107455); + break; + case 224: + if (ts.isExternalModule(container)) { + declareModuleMember(node, 2, 107455); + break; + } + default: + if (!blockScopeContainer.locals) { + blockScopeContainer.locals = {}; + } + declareSymbol(blockScopeContainer.locals, undefined, node, 2, 107455); + } + bindChildren(node, 2, false); + } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } + function bind(node) { + node.parent = parent; + switch (node.kind) { + case 128: + bindDeclaration(node, 262144, 530912, false); + break; + case 129: + bindParameter(node); + break; + case 195: + case 152: + if (ts.isBindingPattern(node.name)) { + bindChildren(node, 0, false); + } + else if (ts.isBlockOrCatchScoped(node)) { + bindBlockScopedVariableDeclaration(node); + } + else { + bindDeclaration(node, 1, 107454, false); + } + break; + case 132: + case 131: + bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); + break; + case 221: + case 222: + bindPropertyOrMethodOrAccessor(node, 4, 107455, false); + break; + case 223: + bindPropertyOrMethodOrAccessor(node, 8, 107455, false); + break; + case 138: + case 139: + case 140: + bindDeclaration(node, 131072, 0, false); + break; + case 134: + case 133: + bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); + break; + case 197: + bindDeclaration(node, 16, 106927, true); + break; + case 135: + bindDeclaration(node, 16384, 0, true); + break; + case 136: + bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); + break; + case 137: + bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); + break; + case 142: + case 143: + bindFunctionOrConstructorType(node); + break; + case 145: + bindAnonymousDeclaration(node, 2048, "__type", false); + break; + case 154: + bindAnonymousDeclaration(node, 4096, "__object", false); + break; + case 162: + case 163: + bindAnonymousDeclaration(node, 16, "__function", true); + break; + case 220: + bindCatchVariableDeclaration(node); + break; + case 198: + bindDeclaration(node, 32, 899583, false); + break; + case 199: + bindDeclaration(node, 64, 792992, false); + break; + case 200: + bindDeclaration(node, 524288, 793056, false); + break; + case 201: + if (ts.isConst(node)) { + bindDeclaration(node, 128, 899967, false); + } + else { + bindDeclaration(node, 256, 899327, false); + } + break; + case 202: + bindModuleDeclaration(node); + break; + case 205: + case 208: + case 210: + case 214: + bindDeclaration(node, 8388608, 8388608, false); + break; + case 207: + if (node.name) { + bindDeclaration(node, 8388608, 8388608, false); + } + else { + bindChildren(node, 0, false); + } + break; + case 212: + if (!node.exportClause) { + declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + } + bindChildren(node, 0, false); + break; + case 211: + if (node.expression && node.expression.kind === 65) { + declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); + } + else { + declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608); + } + bindChildren(node, 0, false); + break; + case 224: + setExportContextFlag(node); + if (ts.isExternalModule(node)) { + bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); + break; + } + case 176: + bindChildren(node, 0, !ts.isFunctionLike(node.parent)); + break; + case 220: + case 183: + case 184: + case 185: + case 204: + bindChildren(node, 0, true); + break; + default: + var saveParent = parent; + parent = node; + ts.forEachChild(node, bind); + parent = saveParent; + } + } + function bindParameter(node) { + if (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node), false); + } + else { + bindDeclaration(node, 1, 107455, false); + } + if (node.flags & 112 && + node.parent.kind === 135 && + node.parent.parent.kind === 198) { + var classDeclaration = node.parent.parent; + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); + } + } + function bindPropertyOrMethodOrAccessor(node, symbolKind, symbolExcludes, isBlockScopeContainer) { + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer); + } + else { + bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer); + } + } + } +})(ts || (ts = {})); +/// var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { @@ -3200,21 +3788,21 @@ var ts; ts.getFullWidth = getFullWidth; function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 32) !== 0; + return (node.parserContextFlags & 64) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 64)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || + if (!(node.parserContextFlags & 128)) { + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 32) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 32; + node.parserContextFlags |= 64; } - node.parserContextFlags |= 64; + node.parserContextFlags |= 128; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 221) { + while (node && node.kind !== 224) { node = node.parent; } return node; @@ -3296,15 +3884,15 @@ var ts; return current; } switch (current.kind) { - case 221: + case 224: + case 204: + case 220: case 202: - case 217: - case 200: - case 181: - case 182: case 183: + case 184: + case 185: return current; - case 174: + case 176: if (!isFunctionLike(current.parent)) { return current; } @@ -3315,9 +3903,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 193 && + declaration.kind === 195 && declaration.parent && - declaration.parent.kind === 217; + declaration.parent.kind === 220; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3354,15 +3942,15 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 193: - case 150: - case 196: - case 197: - case 200: - case 199: - case 220: case 195: - case 160: + case 152: + case 198: + case 199: + case 202: + case 201: + case 223: + case 197: + case 162: errorNode = node.name; break; } @@ -3384,11 +3972,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 199 && isConst(node); + return node.kind === 201 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 150 || isBindingPattern(node))) { + while (node && (node.kind === 152 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3396,14 +3984,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 193) { + if (node.kind === 195) { node = node.parent; } - if (node && node.kind === 194) { + if (node && node.kind === 196) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 175) { + if (node && node.kind === 177) { flags |= node.flags; } return flags; @@ -3418,12 +4006,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 177 && node.expression.kind === 8; + return node.kind === 179 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 128 || node.kind === 127) { + if (node.kind === 129 || node.kind === 128) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3445,23 +4032,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 186: + case 188: return visitor(node); - case 202: - case 174: - case 178: - case 179: + case 204: + case 176: case 180: case 181: case 182: case 183: - case 187: - case 188: - case 214: - case 215: + case 184: + case 185: case 189: - case 191: + case 190: case 217: + case 218: + case 191: + case 193: + case 220: return ts.forEachChild(node, traverse); } } @@ -3470,14 +4057,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 150: - case 220: - case 128: - case 218: - case 130: + case 152: + case 223: case 129: - case 219: - case 193: + case 221: + case 132: + case 131: + case 222: + case 195: return true; } } @@ -3487,22 +4074,22 @@ var ts; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 133: - case 160: - case 195: - case 161: - case 132: - case 131: - case 134: case 135: + case 162: + case 197: + case 163: + case 134: + case 133: case 136: case 137: case 138: + case 139: case 140: - case 141: - case 160: - case 161: - case 195: + case 142: + case 143: + case 162: + case 163: + case 197: return true; } } @@ -3510,11 +4097,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 174 && isFunctionLike(node.parent); + return node && node.kind === 176 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 132 && node.parent.kind === 152; + return node && node.kind === 134 && node.parent.kind === 154; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3533,28 +4120,28 @@ var ts; return undefined; } switch (node.kind) { - case 126: - if (node.parent.parent.kind === 196) { + case 127: + if (node.parent.parent.kind === 198) { return node; } node = node.parent; break; - case 161: + case 163: if (!includeArrowFunctions) { continue; } - case 195: - case 160: - case 200: - case 130: - case 129: + case 197: + case 162: + case 202: case 132: case 131: - case 133: case 134: + case 133: case 135: - case 199: - case 221: + case 136: + case 137: + case 201: + case 224: return node; } } @@ -3566,47 +4153,104 @@ var ts; if (!node) return node; switch (node.kind) { - case 126: - if (node.parent.parent.kind === 196) { + case 127: + if (node.parent.parent.kind === 198) { return node; } node = node.parent; break; - case 195: - case 160: - case 161: + case 197: + case 162: + case 163: if (!includeFunctions) { continue; } - case 130: - case 129: case 132: case 131: - case 133: case 134: + case 133: case 135: + case 136: + case 137: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 157) { + if (node.kind === 159) { return node.tag; } return node.expression; } ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 198: + return true; + case 132: + return node.parent.kind === 198; + case 129: + return node.parent.body && node.parent.parent.kind === 198; + case 136: + case 137: + case 134: + return node.body && node.parent.kind === 198; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + switch (node.kind) { + case 198: + if (node.decorators) { + return true; + } + return false; + case 132: + case 129: + if (node.decorators) { + return true; + } + return false; + case 136: + if (node.body && node.decorators) { + return true; + } + return false; + case 134: + case 137: + if (node.body && node.decorators) { + return true; + } + return false; + } + return false; + } + ts.nodeIsDecorated = nodeIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 198: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 134: + case 137: + return ts.forEach(node.parameters, nodeIsDecorated); + } + return false; + } + ts.childIsDecorated = childIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: case 9: - case 151: - case 152: case 153: case 154: case 155: @@ -3616,68 +4260,70 @@ var ts; case 159: case 160: case 161: - case 164: case 162: case 163: - case 165: case 166: + case 164: + case 165: case 167: case 168: - case 171: case 169: + case 170: + case 173: + case 171: case 10: - case 172: + case 174: return true; - case 125: - while (node.parent.kind === 125) { + case 126: + while (node.parent.kind === 126) { node = node.parent; } - return node.parent.kind === 142; - case 64: - if (node.parent.kind === 142) { + return node.parent.kind === 144; + case 65: + if (node.parent.kind === 144) { return true; } case 7: case 8: - var _parent = node.parent; - switch (_parent.kind) { - case 193: - case 128: - case 130: + var parent_1 = node.parent; + switch (parent_1.kind) { + case 195: case 129: - case 220: - case 218: - case 150: - return _parent.initializer === node; - case 177: - case 178: + case 132: + case 131: + case 223: + case 221: + case 152: + return parent_1.initializer === node; case 179: case 180: - case 186: - case 187: - case 188: - case 214: - case 190: - case 188: - return _parent.expression === node; case 181: - var forStatement = _parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 194) || + case 182: + case 188: + case 189: + case 190: + case 217: + case 192: + case 190: + return parent_1.expression === node; + case 183: + var forStatement = parent_1; + return (forStatement.initializer === node && forStatement.initializer.kind !== 196) || forStatement.condition === node || forStatement.iterator === node; - case 182: - case 183: - var forInStatement = _parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 194) || + case 184: + case 185: + var forInStatement = parent_1; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 196) || forInStatement.expression === node; - case 158: - return node === _parent.expression; - case 173: - return node === _parent.expression; - case 126: - return node === _parent.expression; + case 160: + return node === parent_1.expression; + case 175: + return node === parent_1.expression; + case 127: + return node === parent_1.expression; default: - if (isExpression(_parent)) { + if (isExpression(parent_1)) { return true; } } @@ -3692,7 +4338,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 203 && node.moduleReference.kind === 213; + return node.kind === 205 && node.moduleReference.kind === 216; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3701,41 +4347,41 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 203 && node.moduleReference.kind !== 213; + return node.kind === 205 && node.moduleReference.kind !== 216; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 204) { + if (node.kind === 206) { return node.moduleSpecifier; } - if (node.kind === 203) { + if (node.kind === 205) { var reference = node.moduleReference; - if (reference.kind === 213) { + if (reference.kind === 216) { return reference.expression; } } - if (node.kind === 210) { + if (node.kind === 212) { return node.moduleSpecifier; } } ts.getExternalModuleName = getExternalModuleName; function hasDotDotDotToken(node) { - return node && node.kind === 128 && node.dotDotDotToken !== undefined; + return node && node.kind === 129 && node.dotDotDotToken !== undefined; } ts.hasDotDotDotToken = hasDotDotDotToken; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 128: + case 129: return node.questionToken !== undefined; + case 134: + case 133: + return node.questionToken !== undefined; + case 222: + case 221: case 132: case 131: return node.questionToken !== undefined; - case 219: - case 218: - case 130: - case 129: - return node.questionToken !== undefined; } } return false; @@ -3758,7 +4404,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 149 || node.kind === 148); + return !!node && (node.kind === 151 || node.kind === 150); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -3773,33 +4419,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 161: - case 150: - case 196: - case 133: - case 199: - case 220: - case 212: - case 195: - case 160: - case 134: - case 205: - case 203: - case 208: + case 163: + case 152: + case 198: + case 135: + case 201: + case 223: + case 214: case 197: + case 162: + case 136: + case 207: + case 205: + case 210: + case 199: + case 134: + case 133: + case 202: + case 208: + case 129: + case 221: case 132: case 131: + case 137: + case 222: case 200: - case 206: case 128: - case 218: - case 130: - case 129: - case 135: - case 219: - case 198: - case 127: - case 193: + case 195: return true; } return false; @@ -3807,59 +4453,82 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 185: - case 184: - case 192: - case 179: - case 177: - case 176: - case 182: - case 183: - case 181: - case 178: - case 189: - case 186: - case 188: - case 93: - case 191: - case 175: - case 180: case 187: - case 209: + case 186: + case 194: + case 181: + case 179: + case 178: + case 184: + case 185: + case 183: + case 180: + case 191: + case 188: + case 190: + case 94: + case 193: + case 177: + case 182: + case 189: + case 211: return true; default: return false; } } ts.isStatement = isStatement; + function isClassElement(n) { + switch (n.kind) { + case 135: + case 132: + case 134: + case 136: + case 137: + case 140: + return true; + default: + return false; + } + } + ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 64 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 65 && name.kind !== 8 && name.kind !== 7) { return false; } - var _parent = name.parent; - if (_parent.kind === 208 || _parent.kind === 212) { - if (_parent.propertyName) { + var parent = name.parent; + if (parent.kind === 210 || parent.kind === 214) { + if (parent.propertyName) { return true; } } - if (isDeclaration(_parent)) { - return _parent.name === name; + if (isDeclaration(parent)) { + return parent.name === name; } return false; } ts.isDeclarationName = isDeclarationName; + function isAliasSymbolDeclaration(node) { + return node.kind === 205 || + node.kind === 207 && !!node.name || + node.kind === 208 || + node.kind === 210 || + node.kind === 214 || + node.kind === 211 && node.expression.kind === 65; + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassBaseTypeNode(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 78); + var heritageClause = getHeritageClause(node.heritageClauses, 79); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassBaseTypeNode = getClassBaseTypeNode; function getClassImplementedTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 102); + var heritageClause = getHeritageClause(node.heritageClauses, 103); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 78); + var heritageClause = getHeritageClause(node.heritageClauses, 79); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -3928,7 +4597,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 65 <= token && token <= 124; + return 66 <= token && token <= 125; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -3937,19 +4606,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 126 && + declaration.name.kind === 127 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 153 && isESSymbolIdentifier(node.expression); + return node.kind === 155 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 64 || name.kind === 8 || name.kind === 7) { + if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 126) { + if (name.kind === 127) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -3964,19 +4633,19 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 64 && node.text === "Symbol"; + return node.kind === 65 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 108: - case 106: - case 107: case 109: - case 77: - case 114: - case 69: - case 72: + case 107: + case 108: + case 110: + case 78: + case 115: + case 70: + case 73: return true; } return false; @@ -4092,7 +4761,7 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 200 || n.kind === 221; + return isFunctionLike(n) || n.kind === 202 || n.kind === 224; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4107,26 +4776,6 @@ var ts; return node; } ts.createSynthesizedNode = createSynthesizedNode; - function generateUniqueName(baseName, isExistingName) { - if (baseName.charCodeAt(0) !== 95) { - baseName = "_" + baseName; - if (!isExistingName(baseName)) { - return baseName; - } - } - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var _name = baseName + i; - if (!isExistingName(_name)) { - return _name; - } - i++; - } - } - ts.generateUniqueName = generateUniqueName; function createDiagnosticCollection() { var nonFileDiagnostics = []; var fileDiagnostics = {}; @@ -4227,10 +4876,267 @@ var ts; s; } ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(sourceFile, node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; } + }; + } + ts.createTextWriter = createTextWriter; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 135 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function shouldEmitToOwnFile(sourceFile, compilerOptions) { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { + return true; + } + return false; + } + return false; + } + ts.shouldEmitToOwnFile = shouldEmitToOwnFile; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 136) { + getAccessor = accessor; + } + else if (accessor.kind === 137) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 136 || member.kind === 137) + && (member.flags & 128) === (accessor.flags & 128)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 136 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 137 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + emitLeadingSpace = true; + } + }); + } + ts.emitComments = emitComments; + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + var lineCount = ts.getLineStarts(currentSourceFile).length; + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + if (pos !== comment.pos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + if (currentLineText) { + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + } + ts.writeCommentRange = writeCommentRange; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { - var nodeConstructors = new Array(223); + var nodeConstructors = new Array(226); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -4268,249 +5174,268 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 125: + case 126: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 127: + case 128: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 128: - case 130: case 129: - case 218: - case 219: - case 193: - case 150: - return visitNodes(cbNodes, node.modifiers) || + case 132: + case 131: + case 221: + case 222: + case 195: + case 152: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 140: - case 141: - case 136: - case 137: + case 142: + case 143: case 138: - return visitNodes(cbNodes, node.modifiers) || + case 139: + case 140: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 132: - case 131: - case 133: case 134: + case 133: case 135: - case 160: - case 195: - case 161: - return visitNodes(cbNodes, node.modifiers) || + case 136: + case 137: + case 162: + case 197: + case 163: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 139: + case 141: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 142: - return visitNode(cbNode, node.exprName); - case 143: - return visitNodes(cbNodes, node.members); case 144: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 145: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 146: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.elementType); case 147: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.elementTypes); case 148: + return visitNodes(cbNodes, node.types); case 149: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 150: case 151: return visitNodes(cbNodes, node.elements); - case 152: - return visitNodes(cbNodes, node.properties); case 153: + return visitNodes(cbNodes, node.elements); + case 154: + return visitNodes(cbNodes, node.properties); + case 155: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 154: + case 156: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 155: - case 156: + case 157: + case 158: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 157: + case 159: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 158: + case 160: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 159: - return visitNode(cbNode, node.expression); - case 162: - return visitNode(cbNode, node.expression); - case 163: + case 161: return visitNode(cbNode, node.expression); case 164: return visitNode(cbNode, node.expression); case 165: + return visitNode(cbNode, node.expression); + case 166: + return visitNode(cbNode, node.expression); + case 167: return visitNode(cbNode, node.operand); - case 170: + case 172: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 166: + case 168: return visitNode(cbNode, node.operand); - case 167: + case 169: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 168: + case 170: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 171: + case 173: return visitNode(cbNode, node.expression); - case 174: - case 201: + case 176: + case 203: return visitNodes(cbNodes, node.statements); - case 221: + case 224: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 175: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 194: - return visitNodes(cbNodes, node.declarations); case 177: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 196: + return visitNodes(cbNodes, node.declarations); + case 179: return visitNode(cbNode, node.expression); - case 178: + case 180: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 179: + case 181: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 180: + case 182: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 181: + case 183: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.iterator) || visitNode(cbNode, node.statement); - case 182: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 183: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 184: - case 185: - return visitNode(cbNode, node.label); - case 186: - return visitNode(cbNode, node.expression); - case 187: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 185: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 186: + case 187: + return visitNode(cbNode, node.label); case 188: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 202: - return visitNodes(cbNodes, node.clauses); - case 214: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 215: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 189: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 190: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 204: + return visitNodes(cbNodes, node.clauses); + case 217: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 218: + return visitNodes(cbNodes, node.statements); case 191: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 192: + return visitNode(cbNode, node.expression); + case 193: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 217: + case 220: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 196: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 197: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); + case 130: + return visitNode(cbNode, node.expression); case 198: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 199: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 200: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 199: - return visitNodes(cbNodes, node.modifiers) || + case 201: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 220: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 200: - return visitNodes(cbNodes, node.modifiers) || + case 202: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 203: - return visitNodes(cbNodes, node.modifiers) || + case 205: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 204: - return visitNodes(cbNodes, node.modifiers) || + case 206: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 205: + case 207: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 206: + case 208: return visitNode(cbNode, node.name); - case 207: - case 211: + case 209: + case 213: return visitNodes(cbNodes, node.elements); - case 210: - return visitNodes(cbNodes, node.modifiers) || + case 212: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 208: - case 212: + case 210: + case 214: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 209: - return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 169: + case 211: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 171: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 173: + case 175: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 126: + case 127: return visitNode(cbNode, node.expression); - case 216: + case 219: return visitNodes(cbNodes, node.types); - case 213: + case 216: return visitNode(cbNode, node.expression); + case 215: + return visitNodes(cbNodes, node.decorators); } } ts.forEachChild = forEachChild; @@ -4573,29 +5498,33 @@ var ts; ; function modifierToFlag(token) { switch (token) { - case 109: return 128; - case 108: return 16; - case 107: return 64; - case 106: return 32; - case 77: return 1; - case 114: return 2; - case 69: return 8192; - case 72: return 256; + case 110: return 128; + case 109: return 16; + case 108: return 64; + case 107: return 32; + case 78: return 1; + case 115: return 2; + case 70: return 8192; + case 73: return 256; } return 0; } ts.modifierToFlag = modifierToFlag; function fixupParentReferences(sourceFile) { - var _parent = sourceFile; + // normally parent references are set during binding. However, for clients that only need + // a syntax tree, and no semantic features, then the binding process is an unnecessary + // overhead. This functions allows us to set all the parents, without all the expense of + // binding. + var parent = sourceFile; forEachChild(sourceFile, visitNode); return; function visitNode(n) { - if (n.parent !== _parent) { - n.parent = _parent; - var saveParent = _parent; - _parent = n; + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; forEachChild(n, visitNode); - _parent = saveParent; + parent = saveParent; } } } @@ -4603,7 +5532,7 @@ var ts; switch (node.kind) { case 8: case 7: - case 64: + case 65: return true; } return false; @@ -4813,7 +5742,7 @@ var ts; } ts.updateSourceFile = updateSourceFile; function isEvalOrArgumentsIdentifier(node) { - return node.kind === 64 && + return node.kind === 65 && (node.text === "eval" || node.text === "arguments"); } ts.isEvalOrArgumentsIdentifier = isEvalOrArgumentsIdentifier; @@ -4895,12 +5824,13 @@ var ts; ts.createSourceFile = createSourceFile; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } + var disallowInAndDecoratorContext = 2 | 16; var parsingContext = 0; var identifiers = {}; var identifierCount = 0; var nodeCount = 0; var token; - var sourceFile = createNode(221, 0); + var sourceFile = createNode(224, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -4946,6 +5876,19 @@ var ts; function setGeneratorParameterContext(val) { setContextFlag(val, 8); } + function setDecoratorContext(val) { + setContextFlag(val, 16); + } + function doOutsideOfContext(flags, func) { + var currentContextFlags = contextFlags & flags; + if (currentContextFlags) { + setContextFlag(false, currentContextFlags); + var result = func(); + setContextFlag(true, currentContextFlags); + return result; + } + return func(); + } function allowInAnd(func) { if (contextFlags & 2) { setDisallowInContext(false); @@ -4982,6 +5925,15 @@ var ts; } return func(); } + function doInDecoratorContext(func) { + if (contextFlags & 16) { + return func(); + } + setDecoratorContext(true); + var result = func(); + setDecoratorContext(false); + return result; + } function inYieldContext() { return (contextFlags & 4) !== 0; } @@ -4994,10 +5946,13 @@ var ts; function inDisallowInContext() { return (contextFlags & 2) !== 0; } + function inDecoratorContext() { + return (contextFlags & 16) !== 0; + } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); - var _length = scanner.getTextPos() - start; - parseErrorAtPosition(start, _length, message, arg0); + var length = scanner.getTextPos() - start; + parseErrorAtPosition(start, length, message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { var lastError = ts.lastOrUndefined(sourceFile.parseDiagnostics); @@ -5054,13 +6009,13 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 64) { + if (token === 65) { return true; } - if (token === 110 && inYieldContext()) { + if (token === 111 && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 110 : token > 100; + return inStrictModeContext() ? token > 111 : token > 101; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -5131,7 +6086,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16; + node.parserContextFlags |= 32; } return node; } @@ -5153,12 +6108,12 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(64); + var node = createNode(65); node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(64, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(65, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -5181,7 +6136,7 @@ var ts; return parseIdentifierName(); } function parseComputedPropertyName() { - var node = createNode(126); + var node = createNode(127); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -5205,17 +6160,17 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); } function nextTokenCanFollowContextualModifier() { - if (token === 69) { - return nextToken() === 76; + if (token === 70) { + return nextToken() === 77; } - if (token === 77) { + if (token === 78) { nextToken(); - if (token === 72) { + if (token === 73) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 35 && token !== 14 && canFollowModifier(); } - if (token === 72) { + if (token === 73) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -5229,7 +6184,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 68 || token === 82; + return token === 69 || token === 83; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -5244,7 +6199,7 @@ var ts; case 4: return isStartOfStatement(inErrorRecovery); case 3: - return token === 66 || token === 72; + return token === 67 || token === 73; case 5: return isStartOfTypeMember(); case 6: @@ -5283,8 +6238,8 @@ var ts; return isIdentifier(); } function isNotHeritageClauseTypeName() { - if (token === 102 || - token === 78) { + if (token === 103 || + token === 79) { return lookAhead(nextTokenIsIdentifier); } return false; @@ -5305,13 +6260,13 @@ var ts; case 20: return token === 15; case 4: - return token === 15 || token === 66 || token === 72; + return token === 15 || token === 67 || token === 73; case 8: - return token === 14 || token === 78 || token === 102; + return token === 14 || token === 79 || token === 103; case 9: return isVariableDeclaratorListTerminator(); case 16: - return token === 25 || token === 16 || token === 14 || token === 78 || token === 102; + return token === 25 || token === 16 || token === 14 || token === 79 || token === 103; case 12: return token === 17 || token === 22; case 14: @@ -5404,7 +6359,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 31; + var nodeContextFlags = node.parserContextFlags & 63; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -5450,14 +6405,14 @@ var ts; function isReusableModuleElement(node) { if (node) { switch (node.kind) { - case 204: - case 203: - case 210: - case 209: - case 196: - case 197: - case 200: + case 206: + case 205: + case 212: + case 211: + case 198: case 199: + case 202: + case 201: return true; } return isReusableStatement(node); @@ -5467,12 +6422,12 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 133: - case 138: - case 132: - case 134: case 135: - case 130: + case 140: + case 134: + case 136: + case 137: + case 132: return true; } } @@ -5481,8 +6436,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 214: - case 215: + case 217: + case 218: return true; } } @@ -5491,56 +6446,56 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 195: - case 175: - case 174: - case 178: + case 197: case 177: - case 190: - case 186: - case 188: - case 185: - case 184: - case 182: - case 183: - case 181: - case 180: - case 187: case 176: - case 191: - case 189: + case 180: case 179: case 192: + case 188: + case 190: + case 187: + case 186: + case 184: + case 185: + case 183: + case 182: + case 189: + case 178: + case 193: + case 191: + case 181: + case 194: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 220; + return node.kind === 223; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 137: + case 139: + case 133: + case 140: case 131: case 138: - case 129: - case 136: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 193) { + if (node.kind !== 195) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 128) { + if (node.kind !== 129) { return false; } var parameter = node; @@ -5609,7 +6564,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(125, entity.pos); + var node = createNode(126, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -5620,13 +6575,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(64, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(169); + var template = createNode(171); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -5639,7 +6594,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(173); + var span = createNode(175); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -5673,7 +6628,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(139); + var node = createNode(141); node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 24) { node.typeArguments = parseBracketedList(17, parseType, 24, 25); @@ -5681,15 +6636,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(142); - parseExpected(96); + var node = createNode(144); + parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(127); + var node = createNode(128); node.name = parseIdentifier(); - if (parseOptional(78)) { + if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -5713,7 +6668,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token); + return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 52; } function setModifiers(node, modifiers) { if (modifiers) { @@ -5722,7 +6677,8 @@ var ts; } } function parseParameter() { - var node = createNode(128); + var node = createNode(129); + node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); @@ -5773,8 +6729,8 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 137) { - parseExpected(87); + if (kind === 139) { + parseExpected(88); } fillSignature(51, false, false, node); parseTypeMemberSemicolon(); @@ -5812,9 +6768,9 @@ var ts; nextToken(); return token === 51 || token === 23 || token === 19; } - function parseIndexSignatureDeclaration(modifiers) { - var fullStart = modifiers ? modifiers.pos : scanner.getStartPos(); - var node = createNode(138, fullStart); + function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { + var node = createNode(140, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(15, parseParameter, 18, 19); node.type = parseTypeAnnotation(); @@ -5823,19 +6779,19 @@ var ts; } function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); - var _name = parsePropertyName(); + var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(131, fullStart); - method.name = _name; + var method = createNode(133, fullStart); + method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(129, fullStart); - property.name = _name; + var property = createNode(131, fullStart); + property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -5876,14 +6832,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(136); + return parseSignatureMember(138); case 18: return isIndexSignature() - ? parseIndexSignatureDeclaration(undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 87: + case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(137); + return parseSignatureMember(139); } case 8: case 7: @@ -5901,9 +6857,11 @@ var ts; } } function parseIndexSignatureWithModifiers() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); return isIndexSignature() - ? parseIndexSignatureDeclaration(modifiers) + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) : undefined; } function isStartOfConstructSignature() { @@ -5911,7 +6869,7 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(143); + var node = createNode(145); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -5927,12 +6885,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(145); + var node = createNode(147); node.elementTypes = parseBracketedList(18, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(147); + var node = createNode(149); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -5940,8 +6898,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 141) { - parseExpected(87); + if (kind === 143) { + parseExpected(88); } fillSignature(32, false, false, node); return finishNode(node); @@ -5952,16 +6910,16 @@ var ts; } function parseNonArrayType() { switch (token) { - case 111: - case 120: - case 118: case 112: case 121: + case 119: + case 113: + case 122: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); - case 98: + case 99: return parseTokenNode(); - case 96: + case 97: return parseTypeQuery(); case 14: return parseTypeLiteral(); @@ -5975,17 +6933,17 @@ var ts; } function isStartOfType() { switch (token) { - case 111: - case 120: - case 118: case 112: case 121: - case 98: - case 96: + case 119: + case 113: + case 122: + case 99: + case 97: case 14: case 18: case 24: - case 87: + case 88: return true; case 16: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -6001,7 +6959,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(144, type.pos); + var node = createNode(146, type.pos); node.elementType = type; type = finishNode(node); } @@ -6016,7 +6974,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(146, type.pos); + var node = createNode(148, type.pos); node.types = types; type = finishNode(node); } @@ -6036,7 +6994,7 @@ var ts; if (isIdentifier() || ts.isModifier(token)) { nextToken(); if (token === 51 || token === 23 || - token === 50 || token === 52 || + token === 50 || token === 53 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -6061,10 +7019,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(140); + return parseFunctionOrConstructorType(142); } - if (token === 87) { - return parseFunctionOrConstructorType(141); + if (token === 88) { + return parseFunctionOrConstructorType(143); } return parseUnionTypeOrHigher(); } @@ -6073,11 +7031,11 @@ var ts; } function isStartOfExpression() { switch (token) { - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: case 7: case 8: case 10: @@ -6085,22 +7043,22 @@ var ts; case 16: case 18: case 14: - case 82: - case 87: + case 83: + case 88: case 36: - case 56: + case 57: case 33: case 34: case 47: case 46: - case 73: - case 96: - case 98: + case 74: + case 97: + case 99: case 38: case 39: case 24: - case 64: - case 110: + case 65: + case 111: return true; default: if (isBinaryOperator()) { @@ -6110,26 +7068,45 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && token !== 82 && isStartOfExpression(); + return token !== 14 && token !== 83 && token !== 52 && isStartOfExpression(); } function parseExpression() { + // Expression[in]: + // AssignmentExpression[in] + // Expression[in] , AssignmentExpression[in] + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; while ((operatorToken = parseOptionalToken(23))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } + if (saveDecoratorContext) { + setDecoratorContext(true); + } return expr; } function parseInitializer(inParameter) { - if (token !== 52) { + if (token !== 53) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { return undefined; } } - parseExpected(52); + parseExpected(53); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { + // AssignmentExpression[in,yield]: + // 1) ConditionalExpression[?in,?yield] + // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] + // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] + // 4) ArrowFunctionExpression[?in,?yield] + // 5) [+Yield] YieldExpression[?In] + // + // Note: for ease of implementation we treat productions '2' and '3' as the same thing. + // (i.e. they're both BinaryExpressions with an assignment operator in it). if (isYieldExpression()) { return parseYieldExpression(); } @@ -6138,7 +7115,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 64 && token === 32) { + if (expr.kind === 65 && token === 32) { return parseSimpleArrowFunctionExpression(expr); } if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { @@ -6147,7 +7124,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 110) { + if (token === 111) { if (inYieldContext()) { return true; } @@ -6168,7 +7145,7 @@ var ts; (isIdentifier() || token === 14 || token === 18); } function parseYieldExpression() { - var node = createNode(170); + var node = createNode(172); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -6182,14 +7159,14 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(161, identifier.pos); - var parameter = createNode(128, identifier.pos); + var node = createNode(163, identifier.pos); + var parameter = createNode(129, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - parseExpected(32); + node.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(); return finishNode(node); } @@ -6204,12 +7181,11 @@ var ts; if (!arrowFunction) { return undefined; } - if (parseExpected(32) || token === 14) { - arrowFunction.body = parseArrowFunctionExpressionBody(); - } - else { - arrowFunction.body = parseIdentifier(); - } + var lastToken = token; + arrowFunction.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 32 || lastToken === 14) + ? parseArrowFunctionExpressionBody() + : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { @@ -6259,7 +7235,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(161); + var node = createNode(163); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -6273,7 +7249,7 @@ var ts; if (token === 14) { return parseFunctionBlock(false, false); } - if (isStartOfStatement(true) && !isStartOfExpressionStatement() && token !== 82) { + if (isStartOfStatement(true) && !isStartOfExpressionStatement() && token !== 83) { return parseFunctionBlock(false, true); } return parseAssignmentExpressionOrHigher(); @@ -6283,10 +7259,10 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(168, leftOperand.pos); + var node = createNode(170, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; - node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); node.colonToken = parseExpectedToken(51, false, ts.Diagnostics._0_expected, ts.tokenToString(51)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); @@ -6296,7 +7272,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 85 || t === 124; + return t === 86 || t === 125; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -6305,7 +7281,7 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 85 && inDisallowInContext()) { + if (token === 86 && inDisallowInContext()) { break; } leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); @@ -6313,7 +7289,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 85) { + if (inDisallowInContext() && token === 86) { return false; } return getBinaryOperatorPrecedence() > 0; @@ -6339,8 +7315,8 @@ var ts; case 25: case 26: case 27: + case 87: case 86: - case 85: return 7; case 40: case 41: @@ -6357,33 +7333,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(167, left.pos); + var node = createNode(169, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(165); + var node = createNode(167); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(162); + var node = createNode(164); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(163); + var node = createNode(165); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(164); + var node = createNode(166); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -6397,11 +7373,11 @@ var ts; case 38: case 39: return parsePrefixUnaryExpression(); - case 73: + case 74: return parseDeleteExpression(); - case 96: + case 97: return parseTypeOfExpression(); - case 98: + case 99: return parseVoidExpression(); case 24: return parseTypeAssertion(); @@ -6413,7 +7389,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(166, expression.pos); + var node = createNode(168, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -6422,7 +7398,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 90 + var expression = token === 91 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -6436,14 +7412,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(153, expression.pos); + var node = createNode(155, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(158); + var node = createNode(160); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -6454,15 +7430,15 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(153, expression.pos); + var propertyAccess = createNode(155, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (parseOptional(18)) { - var indexedAccess = createNode(154, expression.pos); + if (!inDecoratorContext() && parseOptional(18)) { + var indexedAccess = createNode(156, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -6476,7 +7452,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(157, expression.pos); + var tagExpression = createNode(159, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -6495,7 +7471,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(155, expression.pos); + var callExpr = createNode(157, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -6503,10 +7479,10 @@ var ts; continue; } else if (token === 16) { - var _callExpr = createNode(155, expression.pos); - _callExpr.expression = expression; - _callExpr.arguments = parseArgumentList(); - expression = finishNode(_callExpr); + var callExpr = createNode(157, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); continue; } return expression; @@ -6562,11 +7538,11 @@ var ts; case 8: case 10: return parseLiteralNode(); - case 92: - case 90: - case 88: - case 94: - case 79: + case 93: + case 91: + case 89: + case 95: + case 80: return parseTokenNode(); case 16: return parseParenthesizedExpression(); @@ -6574,12 +7550,12 @@ var ts; return parseArrayLiteralExpression(); case 14: return parseObjectLiteralExpression(); - case 82: + case 83: return parseFunctionExpression(); - case 87: + case 88: return parseNewExpression(); case 36: - case 56: + case 57: if (reScanSlashToken() === 9) { return parseLiteralNode(); } @@ -6590,28 +7566,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(159); + var node = createNode(161); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(171); + var node = createNode(173); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(172) : + token === 23 ? createNode(174) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { - return allowInAnd(parseArgumentOrArrayLiteralElement); + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(151); + var node = createNode(153); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; @@ -6619,19 +7595,20 @@ var ts; parseExpected(19); return finishNode(node); } - function tryParseAccessorDeclaration(fullStart, modifiers) { - if (parseContextualModifier(115)) { - return parseAccessorDeclaration(134, fullStart, modifiers); + function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { + if (parseContextualModifier(116)) { + return parseAccessorDeclaration(136, fullStart, decorators, modifiers); } - else if (parseContextualModifier(119)) { - return parseAccessorDeclaration(135, fullStart, modifiers); + else if (parseContextualModifier(120)) { + return parseAccessorDeclaration(137, fullStart, decorators, modifiers); } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, modifiers); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } @@ -6641,16 +7618,16 @@ var ts; var propertyName = parsePropertyName(); var questionToken = parseOptionalToken(50); if (asteriskToken || token === 16 || token === 24) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, propertyName, questionToken); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(219, fullStart); + var shorthandDeclaration = createNode(222, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(218, fullStart); + var propertyAssignment = createNode(221, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -6659,7 +7636,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(152); + var node = createNode(154); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; @@ -6669,20 +7646,27 @@ var ts; return finishNode(node); } function parseFunctionExpression() { - var node = createNode(160); - parseExpected(82); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var node = createNode(162); + parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); fillSignature(51, !!node.asteriskToken, false, node); node.body = parseFunctionBlock(!!node.asteriskToken, false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } return finishNode(node); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(156); - parseExpected(87); + var node = createNode(158); + parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 16) { @@ -6691,7 +7675,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(174); + var node = createNode(176); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(2, checkForStrictMode, parseStatement); parseExpected(15); @@ -6704,30 +7688,37 @@ var ts; function parseFunctionBlock(allowYield, ignoreMissingOpenBrace, diagnosticMessage) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } setYieldContext(savedYieldContext); return block; } function parseEmptyStatement() { - var node = createNode(176); + var node = createNode(178); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(178); - parseExpected(83); + var node = createNode(180); + parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(75) ? parseStatement() : undefined; + node.elseStatement = parseOptional(76) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(179); - parseExpected(74); + var node = createNode(181); + parseExpected(75); node.statement = parseStatement(); - parseExpected(99); + parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6735,8 +7726,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(180); - parseExpected(99); + var node = createNode(182); + parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6745,11 +7736,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(81); + parseExpected(82); parseExpected(16); var initializer = undefined; if (token !== 22) { - if (token === 97 || token === 104 || token === 69) { + if (token === 98 || token === 105 || token === 70) { initializer = parseVariableDeclarationList(true); } else { @@ -6757,22 +7748,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(85)) { - var forInStatement = createNode(182, pos); + if (parseOptional(86)) { + var forInStatement = createNode(184, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(124)) { - var forOfStatement = createNode(183, pos); + else if (parseOptional(125)) { + var forOfStatement = createNode(185, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(181, pos); + var forStatement = createNode(183, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -6790,7 +7781,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 185 ? 65 : 70); + parseExpected(kind === 187 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -6798,8 +7789,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(186); - parseExpected(89); + var node = createNode(188); + parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -6807,8 +7798,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(187); - parseExpected(100); + var node = createNode(189); + parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -6816,30 +7807,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(214); - parseExpected(66); + var node = createNode(217); + parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); node.statements = parseList(4, false, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(215); - parseExpected(72); + var node = createNode(218); + parseExpected(73); parseExpected(51); node.statements = parseList(4, false, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 66 ? parseCaseClause() : parseDefaultClause(); + return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(188); - parseExpected(91); + var node = createNode(190); + parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(202, scanner.getStartPos()); + var caseBlock = createNode(204, scanner.getStartPos()); parseExpected(14); caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); parseExpected(15); @@ -6847,26 +7838,28 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(190); - parseExpected(93); + // ThrowStatement[Yield] : + // throw [no LineTerminator here]Expression[In, ?Yield]; + var node = createNode(192); + parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(191); - parseExpected(95); + var node = createNode(193); + parseExpected(96); node.tryBlock = parseBlock(false, false); - node.catchClause = token === 67 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 80) { - parseExpected(80); + node.catchClause = token === 68 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 81) { + parseExpected(81); node.finallyBlock = parseBlock(false, false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(217); - parseExpected(67); + var result = createNode(220); + parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -6875,22 +7868,22 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(192); - parseExpected(71); + var node = createNode(194); + parseExpected(72); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 64 && parseOptional(51)) { - var labeledStatement = createNode(189, fullStart); + if (expression.kind === 65 && parseOptional(51)) { + var labeledStatement = createNode(191, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(177, fullStart); + var expressionStatement = createNode(179, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -6898,7 +7891,7 @@ var ts; } function isStartOfStatement(inErrorRecovery) { if (ts.isModifier(token)) { - var result = lookAhead(parseVariableStatementOrFunctionDeclarationWithModifiers); + var result = lookAhead(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return true; } @@ -6907,39 +7900,39 @@ var ts; case 22: return !inErrorRecovery; case 14: - case 97: - case 104: - case 82: + case 98: + case 105: case 83: - case 74: - case 99: - case 81: - case 70: - case 65: - case 89: + case 84: + case 75: case 100: - case 91: - case 93: - case 95: + case 82: case 71: - case 67: - case 80: + case 66: + case 90: + case 101: + case 92: + case 94: + case 96: + case 72: + case 68: + case 81: return true; - case 69: + case 70: var isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; - case 103: - case 68: - case 116: - case 76: - case 122: + case 104: + case 69: + case 117: + case 77: + case 123: if (isDeclarationStart()) { return false; } - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { return false; } @@ -6949,7 +7942,7 @@ var ts; } function nextTokenIsEnumKeyword() { nextToken(); - return token === 76; + return token === 77; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -6959,46 +7952,46 @@ var ts; switch (token) { case 14: return parseBlock(false, false); - case 97: - case 69: - return parseVariableStatement(scanner.getStartPos(), undefined); - case 82: - return parseFunctionDeclaration(scanner.getStartPos(), undefined); + case 98: + case 70: + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + case 83: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 22: return parseEmptyStatement(); - case 83: + case 84: return parseIfStatement(); - case 74: + case 75: return parseDoStatement(); - case 99: - return parseWhileStatement(); - case 81: - return parseForOrForInOrForOfStatement(); - case 70: - return parseBreakOrContinueStatement(184); - case 65: - return parseBreakOrContinueStatement(185); - case 89: - return parseReturnStatement(); case 100: - return parseWithStatement(); - case 91: - return parseSwitchStatement(); - case 93: - return parseThrowStatement(); - case 95: - case 67: - case 80: - return parseTryStatement(); + return parseWhileStatement(); + case 82: + return parseForOrForInOrForOfStatement(); case 71: + return parseBreakOrContinueStatement(186); + case 66: + return parseBreakOrContinueStatement(187); + case 90: + return parseReturnStatement(); + case 101: + return parseWithStatement(); + case 92: + return parseSwitchStatement(); + case 94: + return parseThrowStatement(); + case 96: + case 68: + case 81: + return parseTryStatement(); + case 72: return parseDebuggerStatement(); - case 104: + case 105: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined); + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } default: - if (ts.isModifier(token)) { - var result = tryParse(parseVariableStatementOrFunctionDeclarationWithModifiers); + if (ts.isModifier(token) || token === 52) { + var result = tryParse(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return result; } @@ -7006,25 +7999,26 @@ var ts; return parseExpressionOrLabeledStatement(); } } - function parseVariableStatementOrFunctionDeclarationWithModifiers() { + function parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers() { var start = scanner.getStartPos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 69: + case 70: var nextTokenIsEnum = lookAhead(nextTokenIsEnumKeyword); if (nextTokenIsEnum) { return undefined; } - return parseVariableStatement(start, modifiers); - case 104: + return parseVariableStatement(start, decorators, modifiers); + case 105: if (!isLetDeclaration()) { return undefined; } - return parseVariableStatement(start, modifiers); - case 97: - return parseVariableStatement(start, modifiers); - case 82: - return parseFunctionDeclaration(start, modifiers); + return parseVariableStatement(start, decorators, modifiers); + case 98: + return parseVariableStatement(start, decorators, modifiers); + case 83: + return parseFunctionDeclaration(start, decorators, modifiers); } return undefined; } @@ -7037,18 +8031,18 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(172); + return createNode(174); } - var node = createNode(150); + var node = createNode(152); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(150); + var node = createNode(152); var id = parsePropertyName(); - if (id.kind === 64 && token !== 51) { + if (id.kind === 65 && token !== 51) { node.name = id; } else { @@ -7060,14 +8054,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(148); + var node = createNode(150); parseExpected(14); node.elements = parseDelimitedList(10, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(149); + var node = createNode(151); parseExpected(18); node.elements = parseDelimitedList(11, parseArrayBindingElement); parseExpected(19); @@ -7086,7 +8080,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(193); + var node = createNode(195); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7095,21 +8089,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(194); + var node = createNode(196); switch (token) { - case 97: + case 98: break; - case 104: + case 105: node.flags |= 4096; break; - case 69: + case 70: node.flags |= 8192; break; default: ts.Debug.fail(); } nextToken(); - if (token === 124 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 125 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -7123,33 +8117,37 @@ var ts; function canFollowContextualOfKeyword() { return nextTokenIsIdentifier() && nextToken() === 17; } - function parseVariableStatement(fullStart, modifiers) { - var node = createNode(175, fullStart); + function parseVariableStatement(fullStart, decorators, modifiers) { + var node = createNode(177, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } - function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(195, fullStart); + function parseFunctionDeclaration(fullStart, decorators, modifiers) { + var node = createNode(197, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(82); + parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); fillSignature(51, !!node.asteriskToken, false, node); node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, ts.Diagnostics.or_expected); return finishNode(node); } - function parseConstructorDeclaration(pos, modifiers) { - var node = createNode(133, pos); + function parseConstructorDeclaration(pos, decorators, modifiers) { + var node = createNode(135, pos); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(113); + parseExpected(114); fillSignature(51, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, ts.Diagnostics.or_expected); return finishNode(node); } - function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(132, fullStart); + function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { + var method = createNode(134, fullStart); + method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; @@ -7158,29 +8156,34 @@ var ts; method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); return finishNode(method); } - function parsePropertyOrMethodDeclaration(fullStart, modifiers) { + function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { + var property = createNode(132, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + property.initializer = allowInAnd(parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(35); - var _name = parsePropertyName(); + var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (asteriskToken || token === 16 || token === 24) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, _name, questionToken, ts.Diagnostics.or_expected); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { - var property = createNode(130, fullStart); - setModifiers(property, modifiers); - property.name = _name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); } } function parseNonParameterInitializer() { return parseInitializer(false); } - function parseAccessorDeclaration(kind, fullStart, modifiers) { + function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); fillSignature(51, false, false, node); @@ -7189,6 +8192,9 @@ var ts; } function isClassMemberStart() { var idToken; + if (token === 52) { + return true; + } while (ts.isModifier(token)) { idToken = token; nextToken(); @@ -7204,14 +8210,14 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 119 || idToken === 115) { + if (!ts.isKeyword(idToken) || idToken === 120 || idToken === 116) { return true; } switch (token) { case 16: case 24: case 51: - case 52: + case 53: case 50: return true; default: @@ -7220,6 +8226,26 @@ var ts; } return false; } + function parseDecorators() { + var decorators; + while (true) { + var decoratorStart = getNodePos(); + if (!parseOptional(52)) { + break; + } + if (!decorators) { + decorators = []; + decorators.pos = scanner.getStartPos(); + } + var decorator = createNode(130, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } function parseModifiers() { var flags = 0; var modifiers; @@ -7244,30 +8270,40 @@ var ts; } function parseClassElement() { var fullStart = getNodePos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, modifiers); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } - if (token === 113) { - return parseConstructorDeclaration(fullStart, modifiers); + if (token === 114) { + return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { - return parseIndexSignatureDeclaration(modifiers); + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } if (isIdentifierOrKeyword() || token === 8 || token === 7 || token === 35 || token === 18) { - return parsePropertyOrMethodDeclaration(fullStart, modifiers); + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + if (decorators) { + var name_3 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_3, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } - function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(196, fullStart); + function parseClassDeclaration(fullStart, decorators, modifiers) { + var savedStrictModeContext = inStrictModeContext(); + if (languageVersion >= 2) { + setStrictModeContext(true); + } + var node = createNode(198, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(68); + parseExpected(69); node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); @@ -7280,9 +8316,14 @@ var ts; else { node.members = createMissingList(); } - return finishNode(node); + var finishedNode = finishNode(node); + setStrictModeContext(savedStrictModeContext); + return finishedNode; } function parseHeritageClauses(isClassHeritageClause) { + // ClassTail[Yield,GeneratorParameter] : See 14.5 + // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } if (isHeritageClause()) { return isClassHeritageClause && inGeneratorParameterContext() ? doOutsideOfYieldContext(parseHeritageClausesWorker) @@ -7294,8 +8335,8 @@ var ts; return parseList(19, false, parseHeritageClause); } function parseHeritageClause() { - if (token === 78 || token === 102) { - var node = createNode(216); + if (token === 79 || token === 103) { + var node = createNode(219); node.token = token; nextToken(); node.types = parseDelimitedList(8, parseTypeReference); @@ -7304,41 +8345,44 @@ var ts; return undefined; } function isHeritageClause() { - return token === 78 || token === 102; + return token === 79 || token === 103; } function parseClassMembers() { return parseList(6, false, parseClassElement); } - function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(197, fullStart); + function parseInterfaceDeclaration(fullStart, decorators, modifiers) { + var node = createNode(199, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(103); + parseExpected(104); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); node.members = parseObjectTypeMembers(); return finishNode(node); } - function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(198, fullStart); + function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { + var node = createNode(200, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(122); + parseExpected(123); node.name = parseIdentifier(); - parseExpected(52); + parseExpected(53); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(220, scanner.getStartPos()); + var node = createNode(223, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } - function parseEnumDeclaration(fullStart, modifiers) { - var node = createNode(199, fullStart); + function parseEnumDeclaration(fullStart, decorators, modifiers) { + var node = createNode(201, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(76); + parseExpected(77); node.name = parseIdentifier(); if (parseExpected(14)) { node.members = parseDelimitedList(7, parseEnumMember); @@ -7350,7 +8394,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(201, scanner.getStartPos()); + var node = createNode(203, scanner.getStartPos()); if (parseExpected(14)) { node.statements = parseList(1, false, parseModuleElement); parseExpected(15); @@ -7360,31 +8404,33 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, modifiers, flags) { - var node = createNode(200, fullStart); + function parseInternalModuleTail(fullStart, decorators, modifiers, flags) { + var node = createNode(202, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(20) - ? parseInternalModuleTail(getNodePos(), undefined, 1) + ? parseInternalModuleTail(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { - var node = createNode(200, fullStart); + function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { + var node = createNode(202, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart, modifiers) { - parseExpected(116); + function parseModuleDeclaration(fullStart, decorators, modifiers) { + parseExpected(117); return token === 8 - ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) - : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) + : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); } function isExternalModuleReference() { - return token === 117 && + return token === 118 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -7393,44 +8439,52 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 123; + token === 124; } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers) { - parseExpected(84); + function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { + parseExpected(85); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 123) { - var importEqualsDeclaration = createNode(203, fullStart); + if (token !== 23 && token !== 124) { + var importEqualsDeclaration = createNode(205, fullStart); + importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(52); + parseExpected(53); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(204, fullStart); + var importDeclaration = createNode(206, fullStart); + importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(123); + parseExpected(124); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(205, fullStart); + //ImportClause: + // ImportedDefaultBinding + // NameSpaceImport + // NamedImports + // ImportedDefaultBinding, NameSpaceImport + // ImportedDefaultBinding, NamedImports + var importClause = createNode(207, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(207); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(209); } return finishNode(importClause); } @@ -7440,8 +8494,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(213); - parseExpected(117); + var node = createNode(216); + parseExpected(118); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -7455,107 +8509,116 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(206); + var namespaceImport = createNode(208); parseExpected(35); - parseExpected(101); + parseExpected(102); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 207 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(20, kind === 209 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(212); + return parseImportOrExportSpecifier(214); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(208); + return parseImportOrExportSpecifier(210); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); - var isFirstIdentifierNameNotAnIdentifier = ts.isKeyword(token) && !isIdentifier(); - var start = scanner.getTokenPos(); + var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + var checkIdentifierStart = scanner.getTokenPos(); + var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 101) { + if (token === 102) { node.propertyName = identifierName; - parseExpected(101); - if (isIdentifier()) { - node.name = parseIdentifierName(); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - } + parseExpected(102); + checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); } else { node.name = identifierName; - if (isFirstIdentifierNameNotAnIdentifier) { - parseErrorAtPosition(start, identifierName.end - start, ts.Diagnostics.Identifier_expected); - } + } + if (kind === 210 && checkIdentifierIsKeyword) { + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } - function parseExportDeclaration(fullStart, modifiers) { - var node = createNode(210, fullStart); + function parseExportDeclaration(fullStart, decorators, modifiers) { + var node = createNode(212, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(123); + parseExpected(124); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(211); - if (parseOptional(123)) { + node.exportClause = parseNamedImportsOrExports(213); + if (parseOptional(124)) { node.moduleSpecifier = parseModuleSpecifier(); } } parseSemicolon(); return finishNode(node); } - function parseExportAssignment(fullStart, modifiers) { - var node = createNode(209, fullStart); + function parseExportAssignment(fullStart, decorators, modifiers) { + var node = createNode(211, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(52)) { + if (parseOptional(53)) { node.isExportEquals = true; + node.expression = parseAssignmentExpressionOrHigher(); } else { - parseExpected(72); + parseExpected(73); + if (parseOptional(51)) { + node.type = parseType(); + } + else { + node.expression = parseAssignmentExpressionOrHigher(); + } } - node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function isLetDeclaration() { return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); } - function isDeclarationStart() { + function isDeclarationStart(followsModifier) { switch (token) { - case 97: - case 69: - case 82: + case 98: + case 70: + case 83: return true; - case 104: + case 105: return isLetDeclaration(); - case 68: - case 103: - case 76: - case 122: - return lookAhead(nextTokenIsIdentifierOrKeyword); - case 84: - return lookAhead(nextTokenCanFollowImportKeyword); - case 116: - return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 69: + case 104: case 77: + case 123: + return lookAhead(nextTokenIsIdentifierOrKeyword); + case 85: + return lookAhead(nextTokenCanFollowImportKeyword); + case 117: + return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 78: return lookAhead(nextTokenCanFollowExportKeyword); - case 114: - case 108: - case 106: - case 107: + case 115: case 109: + case 107: + case 108: + case 110: return lookAhead(nextTokenIsDeclarationStart); + case 52: + return !followsModifier; } } function isIdentifierOrKeyword() { - return token >= 64; + return token >= 65; } function nextTokenIsIdentifierOrKeyword() { nextToken(); @@ -7572,48 +8635,56 @@ var ts; } function nextTokenCanFollowExportKeyword() { nextToken(); - return token === 52 || token === 35 || - token === 14 || token === 72 || isDeclarationStart(); + return token === 53 || token === 35 || + token === 14 || token === 73 || isDeclarationStart(true); } function nextTokenIsDeclarationStart() { nextToken(); - return isDeclarationStart(); + return isDeclarationStart(true); } function nextTokenIsAsKeyword() { - return nextToken() === 101; + return nextToken() === 102; } function parseDeclaration() { var fullStart = getNodePos(); + var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (token === 77) { + if (token === 78) { nextToken(); - if (token === 72 || token === 52) { - return parseExportAssignment(fullStart, modifiers); + if (token === 73 || token === 53) { + return parseExportAssignment(fullStart, decorators, modifiers); } if (token === 35 || token === 14) { - return parseExportDeclaration(fullStart, modifiers); + return parseExportDeclaration(fullStart, decorators, modifiers); } } switch (token) { - case 97: - case 104: + case 98: + case 105: + case 70: + return parseVariableStatement(fullStart, decorators, modifiers); + case 83: + return parseFunctionDeclaration(fullStart, decorators, modifiers); case 69: - return parseVariableStatement(fullStart, modifiers); - case 82: - return parseFunctionDeclaration(fullStart, modifiers); - case 68: - return parseClassDeclaration(fullStart, modifiers); - case 103: - return parseInterfaceDeclaration(fullStart, modifiers); - case 122: - return parseTypeAliasDeclaration(fullStart, modifiers); - case 76: - return parseEnumDeclaration(fullStart, modifiers); - case 116: - return parseModuleDeclaration(fullStart, modifiers); - case 84: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers); + return parseClassDeclaration(fullStart, decorators, modifiers); + case 104: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 123: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 77: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 117: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 85: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); default: + if (decorators) { + var node = createMissingNode(215, true, ts.Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } } @@ -7688,10 +8759,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 203 && node.moduleReference.kind === 213 - || node.kind === 204 - || node.kind === 209 - || node.kind === 210 + || node.kind === 205 && node.moduleReference.kind === 216 + || node.kind === 206 + || node.kind === 211 + || node.kind === 212 ? node : undefined; }); @@ -7700,26 +8771,26 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 153: - case 154: - case 156: case 155: + case 156: + case 158: case 157: - case 151: case 159: - case 152: - case 160: - case 64: + case 153: + case 161: + case 154: + case 162: + case 65: case 9: case 7: case 8: case 10: - case 169: - case 79: - case 88: - case 92: - case 94: - case 90: + case 171: + case 80: + case 89: + case 93: + case 95: + case 91: return true; } } @@ -7727,494 +8798,30 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 52 && token <= 63; + return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; })(ts || (ts = {})); -var ts; -(function (ts) { - ts.bindTime = 0; - (function (ModuleInstanceState) { - ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; - ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; - ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; - })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - var ModuleInstanceState = ts.ModuleInstanceState; - function getModuleInstanceState(node) { - if (node.kind === 197 || node.kind === 198) { - return 0; - } - else if (ts.isConstEnumDeclaration(node)) { - return 2; - } - else if ((node.kind === 204 || node.kind === 203) && !(node.flags & 1)) { - return 0; - } - else if (node.kind === 201) { - var state = 0; - ts.forEachChild(node, function (n) { - switch (getModuleInstanceState(n)) { - case 0: - return false; - case 2: - state = 2; - return false; - case 1: - state = 1; - return true; - } - }); - return state; - } - else if (node.kind === 200) { - return getModuleInstanceState(node.body); - } - else { - return 1; - } - } - ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { - var start = new Date().getTime(); - bindSourceFileWorker(file); - ts.bindTime += new Date().getTime() - start; - } - ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { - var _parent; - var container; - var blockScopeContainer; - var lastContainer; - var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - if (!file.locals) { - file.locals = {}; - container = file; - setBlockScopeContainer(file, false); - bind(file); - file.symbolCount = symbolCount; - } - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function setBlockScopeContainer(node, cleanLocals) { - blockScopeContainer = node; - if (cleanLocals) { - blockScopeContainer.locals = undefined; - } - } - function addDeclarationToSymbol(symbol, node, symbolKind) { - symbol.flags |= symbolKind; - if (!symbol.declarations) - symbol.declarations = []; - symbol.declarations.push(node); - if (symbolKind & 1952 && !symbol.exports) - symbol.exports = {}; - if (symbolKind & 6240 && !symbol.members) - symbol.members = {}; - node.symbol = symbol; - if (symbolKind & 107455 && !symbol.valueDeclaration) - symbol.valueDeclaration = node; - } - function getDeclarationName(node) { - if (node.name) { - if (node.kind === 200 && node.name.kind === 8) { - return '"' + node.name.text + '"'; - } - if (node.name.kind === 126) { - var nameExpression = node.name.expression; - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); - } - return node.name.text; - } - switch (node.kind) { - case 141: - case 133: - return "__constructor"; - case 140: - case 136: - return "__call"; - case 137: - return "__new"; - case 138: - return "__index"; - case 210: - return "__export"; - case 209: - return "default"; - case 195: - case 196: - return node.flags & 256 ? "default" : undefined; - } - } - function getDisplayName(node) { - return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); - } - function declareSymbol(symbols, parent, node, includes, excludes) { - ts.Debug.assert(!ts.hasDynamicName(node)); - var _name = node.flags & 256 && parent ? "default" : getDeclarationName(node); - var symbol; - if (_name !== undefined) { - symbol = ts.hasProperty(symbols, _name) ? symbols[_name] : (symbols[_name] = createSymbol(0, _name)); - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } - var message = symbol.flags & 2 - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0, _name); - } - } - else { - symbol = createSymbol(0, "__missing"); - } - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - if (node.kind === 196 && symbol.exports) { - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - return symbol; - } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) - return true; - node = node.parent; - } - return false; - } - function declareModuleMember(node, symbolKind, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; - if (symbolKind & 8388608) { - if (node.kind === 212 || (node.kind === 203 && hasExportModifier)) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - } - else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - } - } - else { - if (hasExportModifier || isAmbientContext(container)) { - var exportKind = (symbolKind & 107455 ? 1048576 : 0) | - (symbolKind & 793056 ? 2097152 : 0) | - (symbolKind & 1536 ? 4194304 : 0); - var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); - local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - node.localSymbol = local; - } - else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - } - } - } - function bindChildren(node, symbolKind, isBlockScopeContainer) { - if (symbolKind & 255504) { - node.locals = {}; - } - var saveParent = _parent; - var saveContainer = container; - var savedBlockScopeContainer = blockScopeContainer; - _parent = node; - if (symbolKind & 262128) { - container = node; - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; - } - if (isBlockScopeContainer) { - setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 221); - } - ts.forEachChild(node, bind); - container = saveContainer; - _parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { - switch (container.kind) { - case 200: - declareModuleMember(node, symbolKind, symbolExcludes); - break; - case 221: - if (ts.isExternalModule(container)) { - declareModuleMember(node, symbolKind, symbolExcludes); - break; - } - case 140: - case 141: - case 136: - case 137: - case 138: - case 132: - case 131: - case 133: - case 134: - case 135: - case 195: - case 160: - case 161: - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - break; - case 196: - if (node.flags & 128) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - break; - } - case 143: - case 152: - case 197: - declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); - break; - case 199: - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - break; - } - bindChildren(node, symbolKind, isBlockScopeContainer); - } - function bindModuleDeclaration(node) { - if (node.name.kind === 8) { - bindDeclaration(node, 512, 106639, true); - } - else { - var state = getModuleInstanceState(node); - if (state === 0) { - bindDeclaration(node, 1024, 0, true); - } - else { - bindDeclaration(node, 512, 106639, true); - if (state === 2) { - node.symbol.constEnumOnlyModule = true; - } - else if (node.symbol.constEnumOnlyModule) { - node.symbol.constEnumOnlyModule = false; - } - } - } - } - function bindFunctionOrConstructorType(node) { - var symbol = createSymbol(131072, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, 131072); - bindChildren(node, 131072, false); - var typeLiteralSymbol = createSymbol(2048, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048); - typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 140 ? "__call" : "__new"] = symbol; - } - function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { - var symbol = createSymbol(symbolKind, name); - addDeclarationToSymbol(symbol, node, symbolKind); - bindChildren(node, symbolKind, isBlockScopeContainer); - } - function bindCatchVariableDeclaration(node) { - bindChildren(node, 0, true); - } - function bindBlockScopedVariableDeclaration(node) { - switch (blockScopeContainer.kind) { - case 200: - declareModuleMember(node, 2, 107455); - break; - case 221: - if (ts.isExternalModule(container)) { - declareModuleMember(node, 2, 107455); - break; - } - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; - } - declareSymbol(blockScopeContainer.locals, undefined, node, 2, 107455); - } - bindChildren(node, 2, false); - } - function getDestructuringParameterName(node) { - return "__" + ts.indexOf(node.parent.parameters, node); - } - function bind(node) { - node.parent = _parent; - switch (node.kind) { - case 127: - bindDeclaration(node, 262144, 530912, false); - break; - case 128: - bindParameter(node); - break; - case 193: - case 150: - if (ts.isBindingPattern(node.name)) { - bindChildren(node, 0, false); - } - else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); - } - else { - bindDeclaration(node, 1, 107454, false); - } - break; - case 130: - case 129: - bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); - break; - case 218: - case 219: - bindPropertyOrMethodOrAccessor(node, 4, 107455, false); - break; - case 220: - bindPropertyOrMethodOrAccessor(node, 8, 107455, false); - break; - case 136: - case 137: - case 138: - bindDeclaration(node, 131072, 0, false); - break; - case 132: - case 131: - bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); - break; - case 195: - bindDeclaration(node, 16, 106927, true); - break; - case 133: - bindDeclaration(node, 16384, 0, true); - break; - case 134: - bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); - break; - case 135: - bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); - break; - case 140: - case 141: - bindFunctionOrConstructorType(node); - break; - case 143: - bindAnonymousDeclaration(node, 2048, "__type", false); - break; - case 152: - bindAnonymousDeclaration(node, 4096, "__object", false); - break; - case 160: - case 161: - bindAnonymousDeclaration(node, 16, "__function", true); - break; - case 217: - bindCatchVariableDeclaration(node); - break; - case 196: - bindDeclaration(node, 32, 899583, false); - break; - case 197: - bindDeclaration(node, 64, 792992, false); - break; - case 198: - bindDeclaration(node, 524288, 793056, false); - break; - case 199: - if (ts.isConst(node)) { - bindDeclaration(node, 128, 899967, false); - } - else { - bindDeclaration(node, 256, 899327, false); - } - break; - case 200: - bindModuleDeclaration(node); - break; - case 203: - case 206: - case 208: - case 212: - bindDeclaration(node, 8388608, 8388608, false); - break; - case 205: - if (node.name) { - bindDeclaration(node, 8388608, 8388608, false); - } - else { - bindChildren(node, 0, false); - } - break; - case 210: - if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); - } - bindChildren(node, 0, false); - break; - case 209: - if (node.expression.kind === 64) { - declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 8388608); - } - else { - declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455); - } - bindChildren(node, 0, false); - break; - case 221: - if (ts.isExternalModule(node)) { - bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); - break; - } - case 174: - bindChildren(node, 0, !ts.isFunctionLike(node.parent)); - break; - case 217: - case 181: - case 182: - case 183: - case 202: - bindChildren(node, 0, true); - break; - default: - var saveParent = _parent; - _parent = node; - ts.forEachChild(node, bind); - _parent = saveParent; - } - } - function bindParameter(node) { - if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node), false); - } - else { - bindDeclaration(node, 1, 107455, false); - } - if (node.flags & 112 && - node.parent.kind === 133 && - node.parent.parent.kind === 196) { - var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); - } - } - function bindPropertyOrMethodOrAccessor(node, symbolKind, symbolExcludes, isBlockScopeContainer) { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer); - } - else { - bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer); - } - } - } -})(ts || (ts = {})); +/// var ts; (function (ts) { var nextSymbolId = 1; var nextNodeId = 1; var nextMergeId = 1; + function getNodeId(node) { + if (!node.id) + node.id = nextNodeId++; + return node.id; + } + ts.getNodeId = getNodeId; ts.checkTime = 0; + function getSymbolId(symbol) { + if (!symbol.id) { + symbol.id = nextSymbolId++; + } + return symbol.id; + } + ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -8278,7 +8885,6 @@ var ts; var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); var globals = {}; @@ -8295,10 +8901,16 @@ var ts; var globalESSymbolType; var globalIterableType; var anyArrayType; + var globalTypedPropertyDescriptorType; + var globalClassDecoratorType; + var globalParameterDecoratorType; + var globalPropertyDecoratorType; + var globalMethodDecoratorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; var emitExtends = false; + var emitDecorate = false; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -8453,20 +9065,18 @@ var ts; function getSymbolLinks(symbol) { if (symbol.flags & 67108864) return symbol; - if (!symbol.id) - symbol.id = nextSymbolId++; - return symbolLinks[symbol.id] || (symbolLinks[symbol.id] = {}); + var id = getSymbolId(symbol); + return symbolLinks[id] || (symbolLinks[id] = {}); } function getNodeLinks(node) { - if (!node.id) - node.id = nextNodeId++; - return nodeLinks[node.id] || (nodeLinks[node.id] = {}); + var nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 221); + return ts.getAncestor(node, 224); } function isGlobalSourceFile(node) { - return node.kind === 221 && !ts.isExternalModule(node); + return node.kind === 224 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -8500,6 +9110,7 @@ var ts; var lastLocation; var propertyWithInvalidInitializer; var errorLocation = location; + var grandparent; loop: while (location) { if (location.locals && !isGlobalSourceFile(location)) { if (result = getSymbol(location.locals, name, meaning)) { @@ -8507,25 +9118,25 @@ var ts; } } switch (location.kind) { - case 221: + case 224: if (!ts.isExternalModule(location)) break; - case 200: + case 202: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (!(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 212)) { + if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 214)) { break loop; } result = undefined; } break; - case 199: + case 201: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 130: - case 129: - if (location.parent.kind === 196 && !(location.flags & 128)) { + case 132: + case 131: + if (location.parent.kind === 198 && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -8534,8 +9145,8 @@ var ts; } } break; - case 196: - case 197: + case 198: + case 199: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -8544,28 +9155,28 @@ var ts; break loop; } break; - case 126: - var grandparent = location.parent.parent; - if (grandparent.kind === 196 || grandparent.kind === 197) { + case 127: + grandparent = location.parent.parent; + if (grandparent.kind === 198 || grandparent.kind === 199) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 132: - case 131: - case 133: case 134: + case 133: case 135: - case 195: - case 161: + case 136: + case 137: + case 197: + case 163: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 160: + case 162: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -8576,6 +9187,14 @@ var ts; break loop; } break; + case 130: + if (location.parent && location.parent.kind === 129) { + location = location.parent; + } + if (location.parent && ts.isClassElement(location.parent)) { + location = location.parent; + } + break; } lastLocation = location; location = location.parent; @@ -8607,14 +9226,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 193); + var variableDeclaration = ts.getAncestor(declaration, 195); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 175 || - variableDeclaration.parent.parent.kind === 181) { + if (variableDeclaration.parent.parent.kind === 177 || + variableDeclaration.parent.parent.kind === 183) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 183 || - variableDeclaration.parent.parent.kind === 182) { + else if (variableDeclaration.parent.parent.kind === 185 || + variableDeclaration.parent.parent.kind === 184) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -8634,49 +9253,94 @@ var ts; } return false; } - function isAliasSymbolDeclaration(node) { - return node.kind === 203 || - node.kind === 205 && !!node.name || - node.kind === 206 || - node.kind === 208 || - node.kind === 212 || - node.kind === 209; + function getAnyImportSyntax(node) { + if (ts.isAliasSymbolDeclaration(node)) { + if (node.kind === 205) { + return node; + } + while (node && node.kind !== 206) { + node = node.parent; + } + return node; + } } function getDeclarationOfAliasSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return isAliasSymbolDeclaration(d) ? d : undefined; }); + return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 213) { - var moduleSymbol = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node)); - var exportAssignmentSymbol = moduleSymbol && getResolvedExportAssignmentSymbol(moduleSymbol); - return exportAssignmentSymbol || moduleSymbol; + if (node.moduleReference.kind === 216) { + return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportAssignmentSymbol = getResolvedExportAssignmentSymbol(moduleSymbol); - if (!exportAssignmentSymbol) { - error(node.name, ts.Diagnostics.External_module_0_has_no_default_export_or_export_assignment, symbolToString(moduleSymbol)); + var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, ts.Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); } - return exportAssignmentSymbol; + return exportDefaultSymbol; } } function getTargetOfNamespaceImport(node) { - return resolveExternalModuleName(node, node.parent.parent.moduleSpecifier); + var moduleSpecifier = node.parent.parent.moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + function getMemberOfModuleVariable(moduleSymbol, name) { + if (moduleSymbol.flags & 3) { + var typeAnnotation = moduleSymbol.valueDeclaration.type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { + if (valueSymbol.flags & (793056 | 1536)) { + return valueSymbol; + } + var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) + result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) + result.members = typeSymbol.members; + if (valueSymbol.exports) + result.exports = valueSymbol.exports; + return result; + } + function getExportOfModule(symbol, name) { + if (symbol.flags & 1536) { + var exports = getExportsOfSymbol(symbol); + if (ts.hasProperty(exports, name)) { + return resolveSymbol(exports[name]); + } + } + } + function getPropertyOfVariable(symbol, name) { + if (symbol.flags & 3) { + var typeAnnotation = symbol.valueDeclaration.type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } } function getExternalModuleMember(node, specifier) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol) { - var _name = specifier.propertyName || specifier.name; - if (_name.text) { - var symbol = getSymbol(getExportsOfSymbol(moduleSymbol), _name.text, 107455 | 793056 | 1536); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { + var name_4 = specifier.propertyName || specifier.name; + if (name_4.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_4.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_4.text); + var symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; if (!symbol) { - error(_name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(_name)); - return; + error(name_4, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_4)); } - return symbol.flags & (107455 | 793056 | 1536) ? symbol : resolveAlias(symbol); + return symbol; } } } @@ -8689,31 +9353,34 @@ var ts; resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536); } function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793056 | 1536); + return node.expression && resolveEntityName(node.expression, 107455 | 793056 | 1536); } - function getTargetOfImportDeclaration(node) { + function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 203: - return getTargetOfImportEqualsDeclaration(node); case 205: + return getTargetOfImportEqualsDeclaration(node); + case 207: return getTargetOfImportClause(node); - case 206: - return getTargetOfNamespaceImport(node); case 208: + return getTargetOfNamespaceImport(node); + case 210: return getTargetOfImportSpecifier(node); - case 212: + case 214: return getTargetOfExportSpecifier(node); - case 209: + case 211: return getTargetOfExportAssignment(node); } } + function resolveSymbol(symbol) { + return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793056 | 1536)) ? resolveAlias(symbol) : symbol; + } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - var target = getTargetOfImportDeclaration(node); + var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -8738,10 +9405,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 209) { + if (node.kind === 211 && node.expression) { checkExpressionCached(node.expression); } - else if (node.kind === 212) { + else if (node.kind === 214) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -8751,17 +9418,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 203); + importDeclaration = ts.getAncestor(entityName, 205); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 64 && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 65 && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 64 || entityName.parent.kind === 125) { + if (entityName.kind === 65 || entityName.parent.kind === 126) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 203); + ts.Debug.assert(entityName.parent.kind === 205); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -8773,13 +9440,13 @@ var ts; return undefined; } var symbol; - if (name.kind === 64) { + if (name.kind === 65) { symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return undefined; } } - else if (name.kind === 125) { + else if (name.kind === 126) { var namespace = resolveEntityName(name.left, 1536); if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) { return undefined; @@ -8835,22 +9502,22 @@ var ts; } error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["default"]; + function resolveExternalModuleSymbol(moduleSymbol) { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; } - function getResolvedExportAssignmentSymbol(moduleSymbol) { - var symbol = getExportAssignmentSymbol(moduleSymbol); - if (symbol) { - if (symbol.flags & (107455 | 793056 | 1536)) { - return symbol; - } - if (symbol.flags & 8388608) { - return resolveAlias(symbol); - } + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { + var symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (1536 | 3))) { + error(moduleReferenceExpression, ts.Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; } + return symbol; + } + function getExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="]; } function getExportsOfSymbol(symbol) { - return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports; + return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { var links = getSymbolLinks(moduleSymbol); @@ -8864,20 +9531,12 @@ var ts; } } function getExportsForModule(moduleSymbol) { - if (compilerOptions.target < 2) { - var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - return { - "default": defaultSymbol - }; - } - } var result; var visitedSymbols = []; visit(moduleSymbol); return result || moduleSymbol.exports; function visit(symbol) { - if (!ts.contains(visitedSymbols, symbol)) { + if (symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol)) { visitedSymbols.push(symbol); if (symbol !== moduleSymbol) { if (!result) { @@ -8887,9 +9546,10 @@ var ts; } var exportStars = symbol.exports["__export"]; if (exportStars) { - ts.forEach(exportStars.declarations, function (node) { + for (var _i = 0, _a = exportStars.declarations, _n = _a.length; _i < _n; _i++) { + var node = _a[_i]; visit(resolveExternalModuleName(node, node.moduleSpecifier)); - }); + } } } } @@ -8925,7 +9585,7 @@ var ts; var members = node.members; for (var _i = 0, _n = members.length; _i < _n; _i++) { var member = members[_i]; - if (member.kind === 133 && ts.nodeIsPresent(member.body)) { + if (member.kind === 135 && ts.nodeIsPresent(member.body)) { return member; } } @@ -8983,25 +9643,25 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var _location = enclosingDeclaration; _location; _location = _location.parent) { - if (_location.locals && !isGlobalSourceFile(_location)) { - if (result = callback(_location.locals)) { + for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + if (location_1.locals && !isGlobalSourceFile(location_1)) { + if (result = callback(location_1.locals)) { return result; } } - switch (_location.kind) { - case 221: - if (!ts.isExternalModule(_location)) { + switch (location_1.kind) { + case 224: + if (!ts.isExternalModule(location_1)) { break; } - case 200: - if (result = callback(getSymbolOfNode(_location).exports)) { + case 202: + if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 196: - case 197: - if (result = callback(getSymbolOfNode(_location).members)) { + case 198: + case 199: + if (result = callback(getSymbolOfNode(location_1).members)) { return result; } break; @@ -9115,8 +9775,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 200 && declaration.name.kind === 8) || - (declaration.kind === 221 && ts.isExternalModule(declaration)); + return (declaration.kind === 202 && declaration.name.kind === 8) || + (declaration.kind === 224 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -9126,17 +9786,18 @@ var ts; return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 203 && - !(declaration.flags & 1) && - isDeclarationVisible(declaration.parent)) { + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & 1) && + isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, declaration)) { - aliasesToMakeVisible.push(declaration); + if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); } } else { - aliasesToMakeVisible = [declaration]; + aliasesToMakeVisible = [anyImportSyntax]; } return true; } @@ -9147,11 +9808,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 142) { + if (entityName.parent.kind === 144) { meaning = 107455 | 1048576; } - else if (entityName.kind === 125 || - entityName.parent.kind === 203) { + else if (entityName.kind === 126 || + entityName.parent.kind === 205) { meaning = 1536; } else { @@ -9195,10 +9856,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 147) { + while (node.kind === 149) { node = node.parent; } - if (node.kind === 198) { + if (node.kind === 200) { return getSymbolOfNode(node); } } @@ -9352,7 +10013,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 111); + writeKeyword(writer, 112); } } else { @@ -9370,7 +10031,7 @@ var ts; var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { - return declaration.parent.kind === 221 || declaration.parent.kind === 201; + return declaration.parent.kind === 224 || declaration.parent.kind === 203; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -9380,7 +10041,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 96); + writeKeyword(writer, 97); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -9414,7 +10075,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 16); } - writeKeyword(writer, 87); + writeKeyword(writer, 88); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, typeStack); if (flags & 64) { @@ -9433,10 +10094,10 @@ var ts; writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures, _d = _c.length; _b < _d; _b++) { - var _signature = _c[_b]; - writeKeyword(writer, 87); + var signature = _c[_b]; + writeKeyword(writer, 88); writeSpace(writer); - buildSignatureDisplay(_signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); writePunctuation(writer, 22); writer.writeLine(); } @@ -9445,7 +10106,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 120); + writeKeyword(writer, 121); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -9458,7 +10119,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 118); + writeKeyword(writer, 119); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -9472,12 +10133,12 @@ var ts; if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); for (var _h = 0, _j = signatures.length; _h < _j; _h++) { - var _signature_1 = signatures[_h]; + var signature = signatures[_h]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { writePunctuation(writer, 50); } - buildSignatureDisplay(_signature_1, writer, enclosingDeclaration, globalFlagsToPass, typeStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, typeStack); writePunctuation(writer, 22); writer.writeLine(); } @@ -9509,7 +10170,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 78); + writeKeyword(writer, 79); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } @@ -9602,12 +10263,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 200) { + if (node.kind === 202) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 221) { + else if (node.kind === 224) { return ts.isExternalModule(node) ? node : undefined; } } @@ -9650,47 +10311,56 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 193: - case 150: - case 200: - case 196: - case 197: - case 198: + case 152: + return isDeclarationVisible(node.parent.parent); case 195: - case 199: - case 203: - var _parent = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 203 && _parent.kind !== 221 && ts.isInAmbientContext(_parent))) { - return isGlobalSourceFile(_parent) || isUsedInExportAssignment(node); + if (ts.isBindingPattern(node.name) && + !node.name.elements.length) { + return false; } - return isDeclarationVisible(_parent); - case 130: - case 129: - case 134: - case 135: + case 202: + case 198: + case 199: + case 200: + case 197: + case 201: + case 205: + var parent_2 = getDeclarationContainer(node); + if (!(ts.getCombinedNodeFlags(node) & 1) && + !(node.kind !== 205 && parent_2.kind !== 224 && ts.isInAmbientContext(parent_2))) { + return isGlobalSourceFile(parent_2); + } + return isDeclarationVisible(parent_2); case 132: case 131: + case 136: + case 137: + case 134: + case 133: if (node.flags & (32 | 64)) { return false; } - case 133: - case 137: - case 136: - case 138: - case 128: - case 201: - case 140: - case 141: - case 143: + case 135: case 139: - case 144: + case 138: + case 140: + case 129: + case 203: + case 142: + case 143: case 145: + case 141: case 146: case 147: + case 148: + case 149: return isDeclarationVisible(node.parent); - case 127: - case 221: + case 207: + case 208: + case 210: + return false; + case 128: + case 224: return true; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -9704,15 +10374,44 @@ var ts; return links.isVisible; } } + function collectLinkedAliases(node) { + var exportSymbol; + if (node.parent && node.parent.kind === 211) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === 214) { + exportSymbol = getTargetOfExportSpecifier(node.parent); + } + var result = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + function buildVisibleNodeList(declarations) { + ts.forEach(declarations, function (declaration) { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!ts.contains(result, resultNode)) { + result.push(resultNode); + } + if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { + var internalModuleReference = declaration.moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } function getRootDeclaration(node) { - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent.parent; } return node; } function getDeclarationContainer(node) { node = getRootDeclaration(node); - return node.kind === 193 ? node.parent.parent.parent : node.parent; + return node.kind === 195 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -9735,13 +10434,13 @@ var ts; return parentType; } var type; - if (pattern.kind === 148) { - var _name = declaration.propertyName || declaration.name; - type = getTypeOfPropertyOfType(parentType, _name.text) || - isNumericLiteralName(_name.text) && getIndexTypeOfType(parentType, 1) || + if (pattern.kind === 150) { + var name_5 = declaration.propertyName || declaration.name; + type = getTypeOfPropertyOfType(parentType, name_5.text) || + isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(_name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(_name)); + error(name_5, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_5)); return unknownType; } } @@ -9770,10 +10469,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 182) { + if (declaration.parent.parent.kind === 184) { return anyType; } - if (declaration.parent.parent.kind === 183) { + if (declaration.parent.parent.kind === 185) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -9782,10 +10481,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 128) { + if (declaration.kind === 129) { var func = declaration.parent; - if (func.kind === 135 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 134); + if (func.kind === 137 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 136); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -9798,7 +10497,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 219) { + if (declaration.kind === 222) { return checkIdentifier(declaration.name); } return undefined; @@ -9816,8 +10515,8 @@ var ts; var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); - var _name = e.propertyName || e.name; - var symbol = createSymbol(flags, _name.text); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); symbol.type = getTypeFromBindingElement(e); members[symbol.name] = symbol; }); @@ -9827,7 +10526,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 172 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 174 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -9835,7 +10534,7 @@ var ts; return !elementTypes.length ? anyArrayType : hasSpreadElement ? createArrayType(getUnionType(elementTypes)) : createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 148 + return pattern.kind === 150 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -9845,7 +10544,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 218 ? getWidenedType(type) : type; + return declaration.kind !== 221 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -9853,7 +10552,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 128 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 129 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -9866,11 +10565,20 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 217) { + if (declaration.parent.kind === 220) { return links.type = anyType; } - if (declaration.kind === 209) { - return links.type = checkExpression(declaration.expression); + if (declaration.kind === 211) { + var exportAssignment = declaration; + if (exportAssignment.expression) { + return links.type = checkExpression(exportAssignment.expression); + } + else if (exportAssignment.type) { + return links.type = getTypeFromTypeNode(exportAssignment.type); + } + else { + return links.type = anyType; + } } links.type = resolvingType; var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -9894,7 +10602,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 134) { + if (accessor.kind === 136) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -9913,8 +10621,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 134); - var setter = ts.getDeclarationOfKind(symbol, 135); + var getter = ts.getDeclarationOfKind(symbol, 136); + var setter = ts.getDeclarationOfKind(symbol, 137); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -9944,8 +10652,8 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var _getter = ts.getDeclarationOfKind(symbol, 134); - error(_getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + var getter = ts.getDeclarationOfKind(symbol, 136); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } } @@ -10011,7 +10719,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 197 || node.kind === 196) { + if (node.kind === 199 || node.kind === 198) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -10042,7 +10750,7 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(symbol, 196); + var declaration = ts.getDeclarationOfKind(symbol, 198); var baseTypeNode = ts.getClassBaseTypeNode(declaration); if (baseTypeNode) { var baseType = getTypeFromTypeReferenceNode(baseTypeNode); @@ -10083,7 +10791,7 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 197 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 199 && ts.getInterfaceBaseTypeNodes(declaration)) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { @@ -10114,7 +10822,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 198); + var declaration = ts.getDeclarationOfKind(symbol, 200); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -10122,8 +10830,8 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var _declaration = ts.getDeclarationOfKind(symbol, 198); - error(_declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + var declaration = ts.getDeclarationOfKind(symbol, 200); + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; } @@ -10141,7 +10849,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 127).constraint) { + if (!ts.getDeclarationOfKind(symbol, 128).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -10308,8 +11016,8 @@ var ts; return emptyArray; } } - for (var _i_1 = 1; _i_1 < signatureLists.length; _i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[_i_1])) { + for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { + if (!signatureListsIdentical(signatures, signatureLists[i_1])) { return emptyArray; } } @@ -10478,11 +11186,11 @@ var ts; var propTypes = []; var declarations = []; for (var _a = 0, _b = props.length; _a < _b; _a++) { - var _prop = props[_a]; - if (_prop.declarations) { - declarations.push.apply(declarations, _prop.declarations); + var prop = props[_a]; + if (prop.declarations) { + declarations.push.apply(declarations, prop.declarations); } - propTypes.push(getTypeOfSymbol(_prop)); + propTypes.push(getTypeOfSymbol(prop)); } var result = createSymbol(4 | 67108864 | 268435456, name); result.unionType = unionType; @@ -10519,9 +11227,9 @@ var ts; } } if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - var _symbol = getPropertyOfObjectType(globalFunctionType, name); - if (_symbol) - return _symbol; + var symbol = getPropertyOfObjectType(globalFunctionType, name); + if (symbol) + return symbol; } return getPropertyOfObjectType(globalObjectType, name); } @@ -10554,20 +11262,29 @@ var ts; }); return result; } + function symbolsToArray(symbols) { + var result = []; + for (var id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } function getExportsOfExternalModule(node) { if (!node.moduleSpecifier) { return emptyArray; } var module = resolveExternalModuleName(node, node.moduleSpecifier); - if (!module || !module.exports) { + if (!module) { return emptyArray; } - return ts.mapToArray(getExportsOfModule(module)); + return symbolsToArray(getExportsOfModule(module)); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 133 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 135 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -10596,8 +11313,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 134 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 135); + if (declaration.kind === 136 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 137); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -10615,19 +11332,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 140: - case 141: - case 195: - case 132: - case 131: + case 142: + case 143: + case 197: + case 134: case 133: + case 135: + case 138: + case 139: + case 140: case 136: case 137: - case 138: - case 134: - case 135: - case 160: - case 161: + case 162: + case 163: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -10697,7 +11414,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 133 || signature.declaration.kind === 137; + var isConstructor = signature.declaration.kind === 135 || signature.declaration.kind === 139; var type = createObjectType(32768 | 65536); type.members = emptySymbols; type.properties = emptyArray; @@ -10711,7 +11428,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 118 : 120; + var syntaxKind = kind === 1 ? 119 : 121; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -10741,7 +11458,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 127).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 128).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -10791,13 +11508,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 127; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 128; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 139 && n.typeName.kind === 64) { + if (n.kind === 141 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -10862,9 +11579,9 @@ var ts; for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 196: - case 197: + case 198: case 199: + case 201: return declaration; } } @@ -11041,38 +11758,38 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 111: - return anyType; - case 120: - return stringType; - case 118: - return numberType; case 112: - return booleanType; + return anyType; case 121: + return stringType; + case 119: + return numberType; + case 113: + return booleanType; + case 122: return esSymbolType; - case 98: + case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 139: - return getTypeFromTypeReferenceNode(node); - case 142: - return getTypeFromTypeQueryNode(node); - case 144: - return getTypeFromArrayTypeNode(node); - case 145: - return getTypeFromTupleTypeNode(node); - case 146: - return getTypeFromUnionTypeNode(node); - case 147: - return getTypeFromTypeNode(node.type); - case 140: case 141: + return getTypeFromTypeReferenceNode(node); + case 144: + return getTypeFromTypeQueryNode(node); + case 146: + return getTypeFromArrayTypeNode(node); + case 147: + return getTypeFromTupleTypeNode(node); + case 148: + return getTypeFromUnionTypeNode(node); + case 149: + return getTypeFromTypeNode(node.type); + case 142: case 143: + case 145: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 64: - case 125: + case 65: + case 126: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -11135,6 +11852,7 @@ var ts; return function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; return getInferredType(context, i); } } @@ -11222,27 +11940,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 160: - case 161: + case 162: + case 163: return isContextSensitiveFunctionLikeDeclaration(node); - case 152: + case 154: return ts.forEach(node.properties, isContextSensitive); - case 151: + case 153: return ts.forEach(node.elements, isContextSensitive); - case 168: + case 170: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 167: + case 169: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 218: + case 221: return isContextSensitive(node.initializer); - case 132: - case 131: + case 134: + case 133: return isContextSensitiveFunctionLikeDeclaration(node); - case 159: + case 161: return isContextSensitive(node.expression); } return false; @@ -11298,6 +12016,7 @@ var ts; var expandingFlags; var depth = 0; var overflow = false; + var elaborateErrors = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); if (overflow) { @@ -11306,7 +12025,8 @@ var ts; else if (errorInfo) { if (errorInfo.next === undefined) { errorInfo = undefined; - isRelatedTo(source, target, errorNode !== undefined, headMessage, true); + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); } if (containingMessageChain) { errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); @@ -11317,9 +12037,8 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } - function isRelatedTo(source, target, reportErrors, headMessage, elaborateErrors) { - if (elaborateErrors === void 0) { elaborateErrors = false; } - var _result; + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; if (source === target) return -1; if (relation !== identityRelation) { @@ -11343,54 +12062,54 @@ var ts; if (source.flags & 16384 || target.flags & 16384) { if (relation === identityRelation) { if (source.flags & 16384 && target.flags & 16384) { - if (_result = unionTypeRelatedToUnionType(source, target)) { - if (_result &= unionTypeRelatedToUnionType(target, source)) { - return _result; + if (result = unionTypeRelatedToUnionType(source, target)) { + if (result &= unionTypeRelatedToUnionType(target, source)) { + return result; } } } else if (source.flags & 16384) { - if (_result = unionTypeRelatedToType(source, target, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; } } else { - if (_result = unionTypeRelatedToType(target, source, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(target, source, reportErrors)) { + return result; } } } else { if (source.flags & 16384) { - if (_result = unionTypeRelatedToType(source, target, reportErrors)) { - return _result; + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; } } else { - if (_result = typeRelatedToUnionType(source, target, reportErrors)) { - return _result; + if (result = typeRelatedToUnionType(source, target, reportErrors)) { + return result; } } } } else if (source.flags & 512 && target.flags & 512) { - if (_result = typeParameterRelatedTo(source, target, reportErrors)) { - return _result; + if (result = typeParameterRelatedTo(source, target, reportErrors)) { + return result; } } else { var saveErrorInfo = errorInfo; if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (_result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return _result; + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); if (sourceOrApparentType.flags & 48128 && target.flags & 48128 && - (_result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors, elaborateErrors))) { + (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { errorInfo = saveErrorInfo; - return _result; + return result; } } if (reportErrors) { @@ -11406,7 +12125,7 @@ var ts; return 0; } function unionTypeRelatedToUnionType(source, target) { - var _result = -1; + var result = -1; var sourceTypes = source.types; for (var _i = 0, _n = sourceTypes.length; _i < _n; _i++) { var sourceType = sourceTypes[_i]; @@ -11414,9 +12133,9 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typeRelatedToUnionType(source, target, reportErrors) { var targetTypes = target.types; @@ -11429,7 +12148,7 @@ var ts; return 0; } function unionTypeRelatedToType(source, target, reportErrors) { - var _result = -1; + var result = -1; var sourceTypes = source.types; for (var _i = 0, _n = sourceTypes.length; _i < _n; _i++) { var sourceType = sourceTypes[_i]; @@ -11437,20 +12156,20 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typesRelatedTo(sources, targets, reportErrors) { - var _result = -1; + var result = -1; for (var i = 0, len = sources.length; i < len; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function typeParameterRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { @@ -11477,8 +12196,7 @@ var ts; return 0; } } - function objectTypeRelatedTo(source, target, reportErrors, elaborateErrors) { - if (elaborateErrors === void 0) { elaborateErrors = false; } + function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0; } @@ -11516,20 +12234,20 @@ var ts; expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) expandingFlags |= 2; - var _result; + var result; if (expandingFlags === 3) { - _result = 1; + result = 1; } else { - _result = propertiesRelatedTo(source, target, reportErrors); - if (_result) { - _result &= signaturesRelatedTo(source, target, 0, reportErrors); - if (_result) { - _result &= signaturesRelatedTo(source, target, 1, reportErrors); - if (_result) { - _result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (_result) { - _result &= numberIndexTypesRelatedTo(source, target, reportErrors); + result = propertiesRelatedTo(source, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(source, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(source, target, reportErrors); } } } @@ -11537,23 +12255,23 @@ var ts; } expandingFlags = saveExpandingFlags; depth--; - if (_result) { + if (result) { var maybeCache = maybeStack[depth]; - var destinationCache = (_result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; + var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; ts.copyMap(maybeCache, destinationCache); } else { relation[id] = reportErrors ? 3 : 2; } - return _result; + return result; } function isDeeplyNestedGeneric(type, stack) { if (type.flags & 4096 && depth >= 10) { - var _target = type.target; + var target_1 = type.target; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 4096 && t.target === _target) { + if (t.flags & 4096 && t.target === target_1) { count++; if (count >= 10) return true; @@ -11566,7 +12284,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var _result = -1; + var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 131072); for (var _i = 0, _n = properties.length; _i < _n; _i++) { @@ -11621,7 +12339,7 @@ var ts; } return 0; } - _result &= related; + result &= related; if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); @@ -11631,7 +12349,7 @@ var ts; } } } - return _result; + return result; } function propertiesIdenticalTo(source, target) { var sourceProperties = getPropertiesOfObjectType(source); @@ -11639,7 +12357,7 @@ var ts; if (sourceProperties.length !== targetProperties.length) { return 0; } - var _result = -1; + var result = -1; for (var _i = 0, _n = sourceProperties.length; _i < _n; _i++) { var sourceProp = sourceProperties[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); @@ -11650,9 +12368,9 @@ var ts; if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function signaturesRelatedTo(source, target, kind, reportErrors) { if (relation === identityRelation) { @@ -11663,7 +12381,7 @@ var ts; } var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); - var _result = -1; + var result = -1; var saveErrorInfo = errorInfo; outer: for (var _i = 0, _n = targetSignatures.length; _i < _n; _i++) { var t = targetSignatures[_i]; @@ -11674,7 +12392,7 @@ var ts; if (!s.hasStringLiterals || source.flags & 65536) { var related = signatureRelatedTo(s, t, localErrors); if (related) { - _result &= related; + result &= related; errorInfo = saveErrorInfo; continue outer; } @@ -11684,7 +12402,7 @@ var ts; return 0; } } - return _result; + return result; } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -11714,14 +12432,14 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - var _result = -1; + var result = -1; for (var i = 0; i < checkCount; i++) { - var _s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var _t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var s_1 = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t_1 = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - var related = isRelatedTo(_s, _t, reportErrors); + var related = isRelatedTo(s_1, t_1, reportErrors); if (!related) { - related = isRelatedTo(_t, _s, false); + related = isRelatedTo(t_1, s_1, false); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); @@ -11730,13 +12448,13 @@ var ts; } errorInfo = saveErrorInfo; } - _result &= related; + result &= related; } var t = getReturnTypeOfSignature(target); if (t === voidType) - return _result; + return result; var s = getReturnTypeOfSignature(source); - return _result & isRelatedTo(s, t, reportErrors); + return result & isRelatedTo(s, t, reportErrors); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -11744,15 +12462,15 @@ var ts; if (sourceSignatures.length !== targetSignatures.length) { return 0; } - var _result = -1; + var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); if (!related) { return 0; } - _result &= related; + result &= related; } - return _result; + return result; } function stringIndexTypesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { @@ -11872,14 +12590,14 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var _i = 0, _len = source.parameters.length; _i < _len; _i++) { - var s = source.hasRestParameter && _i === _len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[_i]); - var t = target.hasRestParameter && _i === _len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[_i]); - var _related = compareTypes(s, t); - if (!_related) { + for (var i = 0, len = source.parameters.length; i < len; i++) { + var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var related = compareTypes(s, t); + if (!related) { return 0; } - result &= _related; + result &= related; } if (compareReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); @@ -11912,6 +12630,7 @@ var ts; downfallType = types[j]; } } + ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); if (score > bestSupertypeScore) { bestSupertype = types[i]; bestSupertypeDownfallType = downfallType; @@ -11992,17 +12711,17 @@ var ts; return reportWideningErrorsInType(type.typeArguments[0]); } if (type.flags & 131072) { - var _errorReported = false; + var errorReported = false; ts.forEach(getPropertiesOfObjectType(type), function (p) { var t = getTypeOfSymbol(p); if (t.flags & 262144) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } - _errorReported = true; + errorReported = true; } }); - return _errorReported; + return errorReported; } return false; } @@ -12010,22 +12729,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 130: - case 129: + case 132: + case 131: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 128: + case 129: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 195: - case 132: - case 131: + case 197: case 134: - case 135: - case 160: - case 161: + case 133: + case 136: + case 137: + case 162: + case 163: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -12074,12 +12793,11 @@ var ts; var inferences = []; for (var _i = 0, _n = typeParameters.length; _i < _n; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined }); + inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); } return { typeParameters: typeParameters, inferUnionTypes: inferUnionTypes, - inferenceCount: 0, inferences: inferences, inferredTypes: new Array(typeParameters.length) }; @@ -12100,11 +12818,11 @@ var ts; } function isWithinDepthLimit(type, stack) { if (depth >= 5) { - var _target = type.target; + var target_2 = type.target; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 4096 && t.target === _target) { + if (t.flags & 4096 && t.target === target_2) { count++; } } @@ -12121,28 +12839,31 @@ var ts; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { var inferences = context.inferences[i]; - var candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) - candidates.push(source); - break; + if (!inferences.isFixed) { + var candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!ts.contains(candidates, source)) { + candidates.push(source); + } + } + return; } } } else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { var sourceTypes = source.typeArguments; var targetTypes = target.typeArguments; - for (var _i = 0; _i < sourceTypes.length; _i++) { - inferFromTypes(sourceTypes[_i], targetTypes[_i]); + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); } } else if (target.flags & 16384) { - var _targetTypes = target.types; + var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - for (var _a = 0, _n = _targetTypes.length; _a < _n; _a++) { - var t = _targetTypes[_a]; + for (var _i = 0, _n = targetTypes.length; _i < _n; _i++) { + var t = targetTypes[_i]; if (t.flags & 512 && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -12158,9 +12879,9 @@ var ts; } } else if (source.flags & 16384) { - var _sourceTypes = source.types; - for (var _b = 0, _c = _sourceTypes.length; _b < _c; _b++) { - var sourceType = _sourceTypes[_b]; + var sourceTypes = source.types; + for (var _a = 0, _b = sourceTypes.length; _a < _b; _a++) { + var sourceType = sourceTypes[_a]; inferFromTypes(sourceType, target); } } @@ -12224,19 +12945,25 @@ var ts; } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; + var inferenceSucceeded; if (!inferredType) { var inferences = getInferenceCandidates(context, index); if (inferences.length) { var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType; + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; } else { inferredType = emptyObjectType; + inferenceSucceeded = true; } - if (inferredType !== inferenceFailureType) { + if (inferenceSucceeded) { var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + context.failedTypeParameterIndex = index; + } context.inferredTypes[index] = inferredType; } return inferredType; @@ -12260,10 +12987,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 142: + case 144: return true; - case 64: - case 125: + case 65: + case 126: node = node.parent; continue; default: @@ -12303,12 +13030,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 52 && node.operatorToken.kind <= 63) { + if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 159) { + while (n.kind === 161) { n = n.expression; } - if (n.kind === 64 && getResolvedSymbol(n) === symbol) { + if (n.kind === 65 && getResolvedSymbol(n) === symbol) { return true; } } @@ -12322,46 +13049,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 167: + case 169: return isAssignedInBinaryExpression(node); - case 193: - case 150: - return isAssignedInVariableDeclaration(node); - case 148: - case 149: - case 151: + case 195: case 152: + return isAssignedInVariableDeclaration(node); + case 150: + case 151: case 153: case 154: case 155: case 156: + case 157: case 158: - case 159: - case 165: - case 162: - case 163: + case 160: + case 161: + case 167: case 164: + case 165: case 166: case 168: - case 171: - case 174: - case 175: + case 170: + case 173: + case 176: case 177: - case 178: case 179: case 180: case 181: case 182: case 183: - case 186: - case 187: + case 184: + case 185: case 188: - case 214: - case 215: case 189: case 190: - case 191: case 217: + case 218: + case 191: + case 192: + case 193: + case 220: return ts.forEachChild(node, isAssignedIn); } return false; @@ -12369,10 +13096,10 @@ var ts; } function resolveLocation(node) { var containerNodes = []; - for (var _parent = node.parent; _parent; _parent = _parent.parent) { - if ((ts.isExpression(_parent) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(_parent)) { - containerNodes.unshift(_parent); + for (var parent_3 = node.parent; parent_3; parent_3 = parent_3.parent) { + if ((ts.isExpression(parent_3) || ts.isObjectLiteralMethod(node)) && + isContextSensitive(parent_3)) { + containerNodes.unshift(parent_3); } } ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); @@ -12397,17 +13124,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 178: + case 180: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 168: + case 170: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 167: + case 169: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -12417,14 +13144,14 @@ var ts; } } break; - case 221: - case 200: - case 195: - case 132: - case 131: + case 224: + case 202: + case 197: case 134: - case 135: case 133: + case 136: + case 137: + case 135: break loop; } if (narrowedType !== type) { @@ -12437,12 +13164,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 163 || expr.right.kind !== 8) { + if (expr.left.kind !== 165 || expr.right.kind !== 8) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 64 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 65 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -12488,7 +13215,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (type.flags & 1 || !assumeTrue || expr.left.kind !== 64 || getResolvedSymbol(expr.left) !== symbol) { + if (type.flags & 1 || !assumeTrue || expr.left.kind !== 65 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -12510,9 +13237,9 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 159: + case 161: return narrowType(type, expr.expression, assumeTrue); - case 167: + case 169: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -12523,11 +13250,11 @@ var ts; else if (operator === 49) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 86) { + else if (operator === 87) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 165: + case 167: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -12538,7 +13265,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 161) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 163) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -12562,15 +13289,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 217) { + symbol.valueDeclaration.parent.kind === 220) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 194) { + while (container.kind !== 196) { container = container.parent; } container = container.parent; - if (container.kind === 175) { + if (container.kind === 177) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -12587,9 +13314,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 196 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 198 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 130 || container.kind === 133) { + if (container.kind === 132 || container.kind === 135) { getNodeLinks(classNode).flags |= 4; } else { @@ -12599,36 +13326,36 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 161) { + if (container.kind === 163) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 200: + case 202: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 199: + case 201: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 133: + case 135: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 130: - case 129: + case 132: + case 131: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 126: + case 127: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 196 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 198 ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -12637,15 +13364,15 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 128) { + if (n.kind === 129) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 155 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 196); + var isCallExpression = node.parent.kind === 157 && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 198); var baseClass; if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -12660,31 +13387,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 133; + canUseSuperExpression = container.kind === 135; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 161) { + while (container && container.kind === 163) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 196) { + if (container && container.parent && container.parent.kind === 198) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 132 || - container.kind === 131 || - container.kind === 134 || - container.kind === 135; + container.kind === 134 || + container.kind === 133 || + container.kind === 136 || + container.kind === 137; } else { canUseSuperExpression = - container.kind === 132 || + container.kind === 134 || + container.kind === 133 || + container.kind === 136 || + container.kind === 137 || + container.kind === 132 || container.kind === 131 || - container.kind === 134 || - container.kind === 135 || - container.kind === 130 || - container.kind === 129 || - container.kind === 133; + container.kind === 135; } } } @@ -12698,7 +13425,7 @@ var ts; getNodeLinks(node).flags |= 16; returnType = baseClass; } - if (container.kind === 133 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 135 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -12708,7 +13435,7 @@ var ts; return returnType; } } - if (container.kind === 126) { + if (container.kind === 127) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -12746,7 +13473,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 128) { + if (declaration.kind === 129) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -12761,7 +13488,7 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 133 || func.kind === 134 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 135))) { + if (func.type || func.kind === 135 || func.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 137))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } var signature = getContextualSignatureForFunctionLikeDeclaration(func); @@ -12781,7 +13508,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 157) { + if (template.parent.kind === 159) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -12789,7 +13516,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 52 && operator <= 63) { + if (operator >= 53 && operator <= 64) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } @@ -12887,35 +13614,35 @@ var ts; if (node.contextualType) { return node.contextualType; } - var _parent = node.parent; - switch (_parent.kind) { - case 193: - case 128: - case 130: + var parent = node.parent; + switch (parent.kind) { + case 195: case 129: - case 150: + case 132: + case 131: + case 152: return getContextualTypeForInitializerExpression(node); - case 161: - case 186: + case 163: + case 188: return getContextualTypeForReturnExpression(node); - case 155: - case 156: - return getContextualTypeForArgument(_parent, node); + case 157: case 158: - return getTypeFromTypeNode(_parent.type); - case 167: + return getContextualTypeForArgument(parent, node); + case 160: + return getTypeFromTypeNode(parent.type); + case 169: return getContextualTypeForBinaryOperand(node); - case 218: - return getContextualTypeForObjectLiteralElement(_parent); - case 151: + case 221: + return getContextualTypeForObjectLiteralElement(parent); + case 153: return getContextualTypeForElementExpression(node); - case 168: + case 170: return getContextualTypeForConditionalOperand(node); - case 173: - ts.Debug.assert(_parent.parent.kind === 169); - return getContextualTypeForSubstitutionExpression(_parent.parent, node); - case 159: - return getContextualType(_parent); + case 175: + ts.Debug.assert(parent.parent.kind === 171); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 161: + return getContextualType(parent); } return undefined; } @@ -12929,13 +13656,13 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 160 || node.kind === 161; + return node.kind === 162 || node.kind === 163; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -12978,15 +13705,15 @@ var ts; return mapper && mapper !== identityMapper; } function isAssignmentTarget(node) { - var _parent = node.parent; - if (_parent.kind === 167 && _parent.operatorToken.kind === 52 && _parent.left === node) { + var parent = node.parent; + if (parent.kind === 169 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (_parent.kind === 218) { - return isAssignmentTarget(_parent.parent); + if (parent.kind === 221) { + return isAssignmentTarget(parent.parent); } - if (_parent.kind === 151) { - return isAssignmentTarget(_parent); + if (parent.kind === 153) { + return isAssignmentTarget(parent); } return false; } @@ -13007,7 +13734,7 @@ var ts; var elementTypes = []; ts.forEach(elements, function (e) { var type = checkExpression(e, contextualMapper); - if (e.kind === 171) { + if (e.kind === 173) { elementTypes.push(getIndexTypeOfType(type, 1) || anyType); hasSpreadElement = true; } @@ -13024,7 +13751,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 126 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 127 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return allConstituentTypesHaveKind(checkComputedPropertyName(name), 1 | 132); @@ -13054,19 +13781,19 @@ var ts; for (var _i = 0, _a = node.properties, _n = _a.length; _i < _n; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 218 || - memberDecl.kind === 219 || + if (memberDecl.kind === 221 || + memberDecl.kind === 222 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 218) { + if (memberDecl.kind === 221) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 132) { + else if (memberDecl.kind === 134) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 219); - type = memberDecl.name.kind === 126 + ts.Debug.assert(memberDecl.kind === 222); + type = memberDecl.name.kind === 127 ? unknownType : checkExpression(memberDecl.name, contextualMapper); } @@ -13082,7 +13809,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 134 || memberDecl.kind === 135); + ts.Debug.assert(memberDecl.kind === 136 || memberDecl.kind === 137); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -13101,21 +13828,21 @@ var ts; for (var i = 0; i < propertiesArray.length; i++) { var propertyDecl = node.properties[i]; if (kind === 0 || isNumericName(propertyDecl.name)) { - var _type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, _type)) { - propTypes.push(_type); + var type = getTypeOfSymbol(propertiesArray[i]); + if (!ts.contains(propTypes, type)) { + propTypes.push(type); } } } - var _result = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= _result.flags; - return _result; + var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; + typeFlags |= result_1.flags; + return result_1; } return undefined; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 130; + return s.valueDeclaration ? s.valueDeclaration.kind : 132; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -13125,7 +13852,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 196); + var enclosingClassDeclaration = ts.getAncestor(node, 198); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -13134,7 +13861,7 @@ var ts; } return; } - if (left.kind === 90) { + if (left.kind === 91) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -13172,7 +13899,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 90 && getDeclarationKindFromSymbol(prop) !== 132) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -13184,14 +13911,14 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 153 + var left = node.kind === 155 ? node.expression : node.left; var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 90 && getDeclarationKindFromSymbol(prop) !== 132) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { return false; } else { @@ -13206,15 +13933,15 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 156 && node.parent.expression === node) { + if (node.parent.kind === 158 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); } else { - var _start = node.end - "]".length; - var _end = node.end; - grammarErrorAtPos(sourceFile, _start, _end - _start, ts.Diagnostics.Expression_expected); + var start = node.end - "]".length; + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } } var objectType = getApparentType(checkExpression(node.expression)); @@ -13229,15 +13956,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var _name = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (_name !== undefined) { - var prop = getPropertyOfType(objectType, _name); + var name_6 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_6 !== undefined) { + var prop = getPropertyOfType(objectType, name_6); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, _name, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_6, symbolToString(objectType.symbol)); return unknownType; } } @@ -13302,7 +14029,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 157) { + if (node.kind === 159) { checkExpression(node.template); } else { @@ -13327,19 +14054,19 @@ var ts; for (var _i = 0, _n = signatures.length; _i < _n; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var _parent = signature.declaration && signature.declaration.parent; + var parent_4 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && _parent === lastParent) { + if (lastParent && parent_4 === lastParent) { index++; } else { - lastParent = _parent; + lastParent = parent_4; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = _parent; + lastParent = parent_4; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -13355,7 +14082,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 171) { + if (args[i].kind === 173) { return i; } } @@ -13365,11 +14092,11 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 157) { + if (node.kind === 159) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 169) { + if (tagExpression.template.kind === 171) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -13384,7 +14111,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 156); + ts.Debug.assert(callExpression.kind === 158); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -13423,16 +14150,23 @@ var ts; }); return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature, args, excludeArgument) { + function inferTypeArguments(signature, args, excludeArgument, context) { var typeParameters = signature.typeParameters; - var context = createInferenceContext(typeParameters, false); var inferenceMapper = createInferenceMapper(context); + for (var i = 0; i < typeParameters.length; i++) { + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 172) { - var paramType = getTypeAtPosition(signature, arg.kind === 171 ? -1 : i); + if (arg.kind !== 174) { + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 157) { + if (i === 0 && args[i].parent.kind === 159) { argType = globalTemplateStringsArrayType; } else { @@ -13443,22 +14177,15 @@ var ts; } } if (excludeArgument) { - for (var _i = 0; _i < args.length; _i++) { - if (excludeArgument[_i] === false) { - var _arg = args[_i]; - var _paramType = getTypeAtPosition(signature, _arg.kind === 171 ? -1 : _i); - inferTypes(context, checkExpressionWithContextualType(_arg, _paramType, inferenceMapper), _paramType); + for (var i = 0; i < args.length; i++) { + if (excludeArgument[i] === false) { + var arg = args[i]; + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); + inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); } } } - var inferredTypes = getInferredTypes(context); - context.failedTypeParameterIndex = ts.indexOf(inferredTypes, inferenceFailureType); - for (var _i_1 = 0; _i_1 < inferredTypes.length; _i_1++) { - if (inferredTypes[_i_1] === inferenceFailureType) { - inferredTypes[_i_1] = unknownType; - } - } - return context; + getInferredTypes(context); } function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { var typeParameters = signature.typeParameters; @@ -13479,9 +14206,9 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 172) { - var paramType = getTypeAtPosition(signature, arg.kind === 171 ? -1 : i); - var argType = i === 0 && node.kind === 157 ? globalTemplateStringsArrayType : + if (arg.kind !== 174) { + var paramType = getTypeAtPosition(signature, arg.kind === 173 ? -1 : i); + var argType = i === 0 && node.kind === 159 ? globalTemplateStringsArrayType : arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { @@ -13493,10 +14220,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 157) { + if (node.kind === 159) { var template = node.template; args = [template]; - if (template.kind === 169) { + if (template.kind === 171) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -13508,8 +14235,8 @@ var ts; return args; } function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 90) { - var containingClass = ts.getAncestor(callExpression, 196); + if (callExpression.expression.kind === 91) { + var containingClass = ts.getAncestor(callExpression, 198); var baseClassTypeNode = containingClass && ts.getClassBaseTypeNode(containingClass); return baseClassTypeNode && baseClassTypeNode.typeArguments; } @@ -13518,11 +14245,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 157; + var isTaggedTemplate = node.kind === 159; var typeArguments; if (!isTaggedTemplate) { typeArguments = getEffectiveTypeArguments(node); - if (node.expression.kind !== 90) { + if (node.expression.kind !== 91) { ts.forEach(typeArguments, checkSourceElement); } } @@ -13586,56 +14313,57 @@ var ts; } return resolveErrorCall(node); function chooseOverload(candidates, relation) { - for (var _a = 0, _b = candidates.length; _a < _b; _a++) { - var current = candidates[_a]; - if (!hasCorrectArity(node, args, current)) { + for (var _i = 0, _n = candidates.length; _i < _n; _i++) { + var originalCandidate = candidates[_i]; + if (!hasCorrectArity(node, args, originalCandidate)) { continue; } - var originalCandidate = current; - var inferenceResult = void 0; - var _candidate = void 0; + var candidate = void 0; var typeArgumentsAreValid = void 0; + var inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, false) + : undefined; while (true) { - _candidate = originalCandidate; - if (_candidate.typeParameters) { + candidate = originalCandidate; + if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = new Array(_candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(_candidate, typeArguments, typeArgumentTypes, false); + typeArgumentTypes = new Array(candidate.typeParameters.length); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { - inferenceResult = inferTypeArguments(_candidate, args, excludeArgument); - typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0; - typeArgumentTypes = inferenceResult.inferredTypes; + inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; } if (!typeArgumentsAreValid) { break; } - _candidate = getSignatureInstantiation(_candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, _candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; if (index < 0) { - return _candidate; + return candidate; } excludeArgument[index] = false; } if (originalCandidate.typeParameters) { - var instantiatedCandidate = _candidate; + var instantiatedCandidate = candidate; if (typeArgumentsAreValid) { candidateForArgumentError = instantiatedCandidate; } else { candidateForTypeArgumentError = originalCandidate; if (!typeArguments) { - resultOfFailedInference = inferenceResult; + resultOfFailedInference = inferenceContext; } } } else { - ts.Debug.assert(originalCandidate === _candidate); + ts.Debug.assert(originalCandidate === candidate); candidateForArgumentError = originalCandidate; } } @@ -13643,7 +14371,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 90) { + if (node.expression.kind === 91) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1), candidatesOutArray); @@ -13727,13 +14455,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 155) { + if (node.kind === 157) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 156) { + else if (node.kind === 158) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 157) { + else if (node.kind === 159) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -13745,15 +14473,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 90) { + if (node.expression.kind === 91) { return voidType; } - if (node.kind === 156) { + if (node.kind === 158) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 133 && - declaration.kind !== 137 && - declaration.kind !== 141) { + declaration.kind !== 135 && + declaration.kind !== 139 && + declaration.kind !== 143) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -13794,9 +14522,9 @@ var ts; links.type = instantiateType(getTypeAtPosition(context, i), mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - var _parameter = signature.parameters[signature.parameters.length - 1]; - var _links = getSymbolLinks(_parameter); - _links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); + var parameter = signature.parameters[signature.parameters.length - 1]; + var links = getSymbolLinks(parameter); + links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); } } function getReturnTypeFromBody(func, contextualMapper) { @@ -13805,7 +14533,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 174) { + if (func.body.kind !== 176) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -13843,7 +14571,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 190); + return (body.statements.length === 1) && (body.statements[0].kind === 192); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -13852,7 +14580,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 174) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 176) { return; } var bodyBlock = func.body; @@ -13865,9 +14593,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 160) { + if (!hasGrammarError && node.kind === 162) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -13895,19 +14623,19 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 132 && node.kind !== 131) { + if (produceDiagnostics && node.kind !== 134 && node.kind !== 133) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 132 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } if (node.body) { - if (node.body.kind === 174) { + if (node.body.kind === 176) { checkSourceElement(node.body); } else { @@ -13933,17 +14661,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 64: { + case 65: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 153: { - var _symbol = findSymbol(n); - return !_symbol || _symbol === unknownSymbol || (_symbol.flags & ~8) !== 0; + case 155: { + var symbol = findSymbol(n); + return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 154: + case 156: return true; - case 159: + case 161: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -13951,27 +14679,40 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 64: - case 153: { + case 65: + case 155: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 154: { + case 156: { var index = n.argumentExpression; - var _symbol = findSymbol(n.expression); - if (_symbol && index && index.kind === 8) { - var _name = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(_symbol), _name); + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 8) { + var name_7 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_7); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 8192) !== 0; } return false; } - case 159: + case 161: return isConstVariableReference(n.expression); default: return false; } } + function isImportedNameFromExternalModule(n) { + switch (n.kind) { + case 156: + case 155: { + var symbol = findSymbol(n.expression); + return symbol && symbol.flags & 8388608 && isExternalModuleSymbol(resolveAlias(symbol)); + } + case 161: + return isImportedNameFromExternalModule(n.expression); + default: + return false; + } + } if (!isReferenceOrErrorExpression(n)) { error(n, invalidReferenceMessage); return false; @@ -13980,10 +14721,13 @@ var ts; error(n, constantVariableMessage); return false; } + if (isImportedNameFromExternalModule(n)) { + error(n, invalidReferenceMessage); + } return true; } function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 && node.expression.kind === 64) { + if (node.parserContextFlags & 1 && node.expression.kind === 65) { grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); } var operandType = checkExpression(node.expression); @@ -14091,17 +14835,17 @@ var ts; var properties = node.properties; for (var _i = 0, _n = properties.length; _i < _n; _i++) { var p = properties[_i]; - if (p.kind === 218 || p.kind === 219) { - var _name = p.name; + if (p.kind === 221 || p.kind === 222) { + var name_8 = p.name; var type = sourceType.flags & 1 ? sourceType : - getTypeOfPropertyOfType(sourceType, _name.text) || - isNumericLiteralName(_name.text) && getIndexTypeOfType(sourceType, 1) || + getTypeOfPropertyOfType(sourceType, name_8.text) || + isNumericLiteralName(name_8.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || _name, type); + checkDestructuringAssignment(p.initializer || name_8, type); } else { - error(_name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(_name)); + error(name_8, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_8)); } } else { @@ -14118,8 +14862,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 172) { - if (e.kind !== 171) { + if (e.kind !== 174) { + if (e.kind !== 173) { var propName = "" + i; var type = sourceType.flags & 1 ? sourceType : isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) : @@ -14149,14 +14893,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 167 && target.operatorToken.kind === 52) { + if (target.kind === 169 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 152) { + if (target.kind === 154) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 151) { + if (target.kind === 153) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -14173,32 +14917,32 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operatorToken.kind; - if (operator === 52 && (node.left.kind === 152 || node.left.kind === 151)) { + if (operator === 53 && (node.left.kind === 154 || node.left.kind === 153)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { case 35: - case 55: - case 36: case 56: - case 37: + case 36: case 57: - case 34: - case 54: - case 40: + case 37: case 58: - case 41: + case 34: + case 55: + case 40: case 59: - case 42: + case 41: case 60: - case 44: - case 62: - case 45: - case 63: - case 43: + case 42: case 61: + case 44: + case 63: + case 45: + case 64: + case 43: + case 62: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -14218,7 +14962,7 @@ var ts; } return numberType; case 33: - case 53: + case 54: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -14242,7 +14986,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 53) { + if (operator === 54) { checkAssignmentOperator(resultType); } return resultType; @@ -14261,15 +15005,15 @@ var ts; reportOperatorError(); } return booleanType; - case 86: + case 87: return checkInstanceOfExpression(node, leftType, rightType); - case 85: + case 86: return checkInExpression(node, leftType, rightType); case 48: return rightType; case 49: return getUnionType([leftType, rightType]); - case 52: + case 53: checkAssignmentOperator(rightType); return rightType; case 23: @@ -14288,20 +15032,20 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 44: - case 62: + case 63: return 49; case 45: - case 63: + case 64: return 31; case 43: - case 61: + case 62: return 48; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 52 && operator <= 63) { + if (produceDiagnostics && operator >= 53 && operator <= 64) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -14347,14 +15091,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -14380,7 +15124,7 @@ var ts; } function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 125) { + if (node.kind == 126) { type = checkQualifiedName(node); } else { @@ -14388,9 +15132,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 153 && node.parent.expression === node) || - (node.parent.kind === 154 && node.parent.expression === node) || - ((node.kind === 64 || node.kind === 125) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 155 && node.parent.expression === node) || + (node.parent.kind === 156 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 126) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -14403,65 +15147,65 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 64: + case 65: return checkIdentifier(node); - case 92: + case 93: return checkThisExpression(node); - case 90: + case 91: return checkSuperExpression(node); - case 88: + case 89: return nullType; - case 94: - case 79: + case 95: + case 80: return booleanType; case 7: return checkNumericLiteral(node); - case 169: + case 171: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 151: - return checkArrayLiteral(node, contextualMapper); - case 152: - return checkObjectLiteral(node, contextualMapper); case 153: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 154: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 155: + return checkPropertyAccessExpression(node); case 156: - return checkCallExpression(node); + return checkIndexedAccess(node); case 157: - return checkTaggedTemplateExpression(node); case 158: - return checkTypeAssertion(node); + return checkCallExpression(node); case 159: - return checkExpression(node.expression, contextualMapper); + return checkTaggedTemplateExpression(node); case 160: + return checkTypeAssertion(node); case 161: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 163: - return checkTypeOfExpression(node); + return checkExpression(node.expression, contextualMapper); case 162: - return checkDeleteExpression(node); - case 164: - return checkVoidExpression(node); + case 163: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 165: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 164: + return checkDeleteExpression(node); case 166: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 167: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 168: - return checkConditionalExpression(node, contextualMapper); - case 171: - return checkSpreadElementExpression(node, contextualMapper); - case 172: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 169: + return checkBinaryExpression(node, contextualMapper); case 170: + return checkConditionalExpression(node, contextualMapper); + case 173: + return checkSpreadElementExpression(node, contextualMapper); + case 174: + return undefinedType; + case 172: checkYieldExpression(node); return unknownType; } @@ -14478,12 +15222,18 @@ var ts; } } function checkParameter(node) { - checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + // Grammar checking + // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the + // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code + // or if its FunctionBody is strict code(11.1.5). + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 133 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 135 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -14497,12 +15247,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 138) { + if (node.kind === 140) { checkGrammarIndexSignature(node); } - else if (node.kind === 140 || node.kind === 195 || node.kind === 141 || - node.kind === 136 || node.kind === 133 || - node.kind === 137) { + else if (node.kind === 142 || node.kind === 197 || node.kind === 143 || + node.kind === 138 || node.kind === 135 || + node.kind === 139) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -14514,10 +15264,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 137: + case 139: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 136: + case 138: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -14526,7 +15276,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 197) { + if (node.kind === 199) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14541,7 +15291,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 120: + case 121: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -14549,7 +15299,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 118: + case 119: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -14563,7 +15313,7 @@ var ts; } } function checkPropertyDeclaration(node) { - checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); } function checkMethodDeclaration(node) { @@ -14586,30 +15336,30 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 155 && n.expression.kind === 90; + return n.kind === 157 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 160: - case 195: - case 161: - case 152: return false; + case 162: + case 197: + case 163: + case 154: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 92) { + if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 160 && n.kind !== 195) { + else if (n.kind !== 162 && n.kind !== 197) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 130 && + return n.kind === 132 && !(n.flags & 128) && !!n.initializer; } @@ -14619,7 +15369,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 177 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 179 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -14635,13 +15385,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 134) { + if (node.kind === 136) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 134 ? 135 : 134; + var otherKind = node.kind === 136 ? 137 : 136; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -14660,6 +15410,9 @@ var ts; } checkFunctionLikeDeclaration(node); } + function checkMissingDeclaration(node) { + checkDecorators(node); + } function checkTypeReference(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReferenceNode(node); @@ -14715,9 +15468,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 197) { - ts.Debug.assert(signatureDeclarationNode.kind === 136 || signatureDeclarationNode.kind === 137); - var signatureKind = signatureDeclarationNode.kind === 136 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 199) { + ts.Debug.assert(signatureDeclarationNode.kind === 138 || signatureDeclarationNode.kind === 139); + var signatureKind = signatureDeclarationNode.kind === 138 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -14735,7 +15488,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 197 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 199 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -14806,16 +15559,16 @@ var ts; }); if (subsequentNode) { if (subsequentNode.kind === node.kind) { - var _errorNode = subsequentNode.name || subsequentNode; + var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 132 || node.kind === 131); + ts.Debug.assert(node.kind === 134 || node.kind === 133); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; - error(_errorNode, diagnostic); + error(errorNode_1, diagnostic); return; } else if (ts.nodeIsPresent(subsequentNode.body)) { - error(_errorNode, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); + error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); return; } } @@ -14835,11 +15588,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 197 || node.parent.kind === 143 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 199 || node.parent.kind === 145 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 195 || node.kind === 132 || node.kind === 131 || node.kind === 133) { + if (node.kind === 197 || node.kind === 134 || node.kind === 133 || node.kind === 135) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -14936,16 +15689,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 197: + case 199: return 2097152; - case 200: + case 202: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 196: - case 199: + case 198: + case 201: return 2097152 | 1048576; - case 203: + case 205: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -14955,6 +15708,49 @@ var ts; } } } + function checkDecorator(node) { + var expression = node.expression; + var exprType = checkExpression(expression); + switch (node.parent.kind) { + case 198: + var classSymbol = getSymbolOfNode(node.parent); + var classConstructorType = getTypeOfSymbol(classSymbol); + var classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + checkTypeAssignableTo(exprType, classDecoratorType, node); + break; + case 132: + checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + break; + case 134: + case 136: + case 137: + var methodType = getTypeOfNode(node.parent); + var methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + checkTypeAssignableTo(exprType, methodDecoratorType, node); + break; + case 129: + checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + break; + } + } + function checkDecorators(node) { + if (!node.decorators) { + return; + } + switch (node.kind) { + case 198: + case 134: + case 136: + case 137: + case 132: + case 129: + emitDecorate = true; + break; + default: + return; + } + ts.forEach(node.decorators, checkDecorator); + } function checkFunctionDeclaration(node) { if (produceDiagnostics) { checkFunctionLikeDeclaration(node) || @@ -14967,8 +15763,9 @@ var ts; } } function checkFunctionLikeDeclaration(node) { + checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 126) { + if (node.name && node.name.kind === 127) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -14993,11 +15790,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 174) { + if (node.kind === 176) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 201) { + if (ts.isFunctionBlock(node) || node.kind === 203) { checkFunctionExpressionBodies(node); } } @@ -15015,19 +15812,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 130 || - node.kind === 129 || - node.kind === 132 || + if (node.kind === 132 || node.kind === 131 || node.kind === 134 || - node.kind === 135) { + node.kind === 133 || + node.kind === 136 || + node.kind === 137) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = getRootDeclaration(node); - if (root.kind === 128 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 129 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -15041,8 +15838,8 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var _isDeclaration = node.kind !== 64; - if (_isDeclaration) { + var isDeclaration_1 = node.kind !== 65; + if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { @@ -15057,13 +15854,13 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 196); + var enclosingClass = ts.getAncestor(node, 198); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } if (ts.getClassBaseTypeNode(enclosingClass)) { - var _isDeclaration = node.kind !== 64; - if (_isDeclaration) { + var isDeclaration_2 = node.kind !== 65; + if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -15075,56 +15872,65 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 200 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 202 && ts.getModuleInstanceState(node) !== 1) { return; } - var _parent = getDeclarationContainer(node); - if (_parent.kind === 221 && ts.isExternalModule(_parent)) { + var parent = getDeclarationContainer(node); + if (parent.kind === 224 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkVarDeclaredNamesNotShadowed(node) { - if (node.initializer && (ts.getCombinedNodeFlags(node) & 12288) === 0) { - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); - if (localDeclarationSymbol && - localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 194); - var container = varDeclList.parent.kind === 175 && - varDeclList.parent.parent; - var namesShareScope = container && - (container.kind === 174 && ts.isFunctionLike(container.parent) || - (container.kind === 201 && container.kind === 200) || - container.kind === 221); - if (!namesShareScope) { - var _name = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, _name, _name); - } + // - ScriptBody : StatementList + // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList + // also occurs in the VarDeclaredNames of StatementList. + if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || isParameterDeclaration(node)) { + return; + } + if (node.kind === 195 && !node.initializer) { + return; + } + var symbol = getSymbolOfNode(node); + if (symbol.flags & 1) { + var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); + if (localDeclarationSymbol && + localDeclarationSymbol !== symbol && + localDeclarationSymbol.flags & 2) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 196); + var container = varDeclList.parent.kind === 177 && varDeclList.parent.parent + ? varDeclList.parent.parent + : undefined; + var namesShareScope = container && + (container.kind === 176 && ts.isFunctionLike(container.parent) || + container.kind === 203 || + container.kind === 202 || + container.kind === 224); + if (!namesShareScope) { + var name_9 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_9, name_9); } } } } } function isParameterDeclaration(node) { - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent.parent; } - return node.kind === 128; + return node.kind === 129; } function checkParameterInitializer(node) { - if (getRootDeclaration(node).kind !== 128) { + if (getRootDeclaration(node).kind !== 129) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 64) { + if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 128) { + if (referencedSymbol.valueDeclaration.kind === 129) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -15142,8 +15948,9 @@ var ts; } } function checkVariableLikeDeclaration(node) { + checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 126) { + if (node.name.kind === 127) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -15152,7 +15959,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && getRootDeclaration(node).kind === 128 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && getRootDeclaration(node).kind === 129 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -15180,9 +15987,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 130 && node.kind !== 129) { + if (node.kind !== 132 && node.kind !== 131) { checkExportsOnMergedDeclarations(node); - if (node.kind === 193 || node.kind === 150) { + if (node.kind === 195 || node.kind === 152) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -15199,7 +16006,7 @@ var ts; return checkVariableLikeDeclaration(node); } function checkVariableStatement(node) { - checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + checkGrammarDecorators(node) || checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) { @@ -15211,7 +16018,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 174 || node.kind === 152) { + if (node.kind === 176 || node.kind === 154) { return true; } node = node.parent; @@ -15239,12 +16046,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 194) { + if (node.initializer && node.initializer.kind == 196) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -15259,13 +16066,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 151 || varExpr.kind === 152) { + if (varExpr.kind === 153 || varExpr.kind === 154) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -15280,7 +16087,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -15290,7 +16097,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 151 || varExpr.kind === 152) { + if (varExpr.kind === 153 || varExpr.kind === 154) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!allConstituentTypesHaveKind(leftType, 1 | 258)) { @@ -15330,6 +16137,31 @@ var ts; } return iteratedType; function getIteratedType(iterable, expressionForError) { + // We want to treat type as an iterable, and get the type it is an iterable of. The iterable + // must have the following structure (annotated with the names of the variables below): + // + // { // iterable + // [Symbol.iterator]: { // iteratorFunction + // (): { // iterator + // next: { // iteratorNextFunction + // (): { // iteratorNextResult + // value: T // iteratorNextValue + // } + // } + // } + // } + // } + // + // T is the type we are after. At every level that involves analyzing return types + // of signatures, we union the return types of all the signatures. + // + // Another thing to note is that at any step of this process, we could run into a dead end, + // meaning either the property is missing, or we run into the anyType. If either of these things + // happens, we return undefined to signal that we could not find the iterated type. If a property + // is missing, and the previous step did not result in 'any', then we also give an error if the + // caller requested it. Then the caller can decide what to do in the case where there is no iterated + // type. This is different from returning anyType, because that would signify that we have matched the + // whole pattern and that T (above) is 'any'. if (allConstituentTypesHaveKind(iterable, 1)) { return undefined; } @@ -15409,7 +16241,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 134 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 135))); + return !!(node.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 137))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -15423,11 +16255,11 @@ var ts; if (func) { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); var exprType = checkExpressionCached(node.expression); - if (func.kind === 135) { + if (func.kind === 137) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - if (func.kind === 133) { + if (func.kind === 135) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -15454,7 +16286,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 215 && !hasDuplicateDefaultClause) { + if (clause.kind === 218 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -15466,7 +16298,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 214) { + if (produceDiagnostics && clause.kind === 217) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -15483,7 +16315,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 189 && current.label.text === node.label.text) { + if (current.kind === 191 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -15509,7 +16341,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 64) { + if (catchClause.variableDeclaration.name.kind !== 65) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -15547,7 +16379,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 196) { + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 198) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members, _n = _a.length; _i < _n; _i++) { var member = _a[_i]; @@ -15577,22 +16409,22 @@ var ts; if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { return; } - var _errorNode; - if (prop.valueDeclaration.name.kind === 126 || prop.parent === containingType.symbol) { - _errorNode = prop.valueDeclaration; + var errorNode; + if (prop.valueDeclaration.name.kind === 127 || prop.parent === containingType.symbol) { + errorNode = prop.valueDeclaration; } else if (indexDeclaration) { - _errorNode = indexDeclaration; + errorNode = indexDeclaration; } else if (containingType.flags & 2048) { var someBaseClassHasBothPropertyAndIndexer = ts.forEach(containingType.baseTypes, function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - _errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; } - if (_errorNode && !isTypeAssignableTo(propertyType, indexType)) { + if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(_errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); } } } @@ -15624,6 +16456,7 @@ var ts; } function checkClassDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); + checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); @@ -15680,6 +16513,19 @@ var ts; return s.flags & 16777216 ? getSymbolLinks(s).target : s; } function checkKindsOfPropertyMemberOverrides(type, baseType) { + // TypeScript 1.0 spec (April 2014): 8.2.3 + // A derived class inherits all members from its base class it doesn't override. + // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. + // Both public and private property members are inherited, but only public property members can be overridden. + // A property member in a derived class is said to override a property member in a base class + // when the derived class property member has the same name and kind(instance or static) + // as the base class property member. + // The type of an overriding property member must be assignable(section 3.8.4) + // to the type of the overridden property member, or otherwise a compile - time error occurs. + // Base class instance member functions can be overridden by derived class instance member functions, + // but not by other kinds of members. + // Base class instance member variables and accessors can be overridden by + // derived class instance member variables and accessors, but not by other kinds of members. var baseProperties = getPropertiesOfObjectType(baseType); for (var _i = 0, _n = baseProperties.length; _i < _n; _i++) { var baseProperty = baseProperties[_i]; @@ -15724,7 +16570,7 @@ var ts; } } function isAccessor(kind) { - return kind === 134 || kind === 135; + return kind === 136 || kind === 137; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -15783,13 +16629,13 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 197); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 199); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15812,25 +16658,25 @@ var ts; } } function checkTypeAliasDeclaration(node) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); } function computeEnumMemberValues(node) { - var _nodeLinks = getNodeLinks(node); - if (!(_nodeLinks.flags & 128)) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 128)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 126 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 127 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); + autoValue = getConstantValueForEnumMemberInitializer(initializer); if (autoValue === undefined) { if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); @@ -15855,13 +16701,13 @@ var ts; getNodeLinks(member).enumMemberValue = autoValue++; } }); - _nodeLinks.flags |= 128; + nodeLinks.flags |= 128; } - function getConstantValueForEnumMemberInitializer(initializer, enumIsConst) { + function getConstantValueForEnumMemberInitializer(initializer) { return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 165: + case 167: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -15869,13 +16715,10 @@ var ts; switch (e.operator) { case 33: return value; case 34: return -value; - case 47: return enumIsConst ? ~value : undefined; + case 47: return ~value; } return undefined; - case 167: - if (!enumIsConst) { - return undefined; - } + case 169: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -15900,43 +16743,54 @@ var ts; return undefined; case 7: return +e.text; - case 159: - return enumIsConst ? evalConstant(e.expression) : undefined; - case 64: - case 154: - case 153: - if (!enumIsConst) { - return undefined; - } + case 161: + return evalConstant(e.expression); + case 65: + case 156: + case 155: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var _enumType; + var enumType; var propertyName; - if (e.kind === 64) { - _enumType = currentType; + if (e.kind === 65) { + enumType = currentType; propertyName = e.text; } else { - if (e.kind === 154) { + var expression; + if (e.kind === 156) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; } - _enumType = getTypeOfNode(e.expression); + expression = e.expression; propertyName = e.argumentExpression.text; } else { - _enumType = getTypeOfNode(e.expression); + expression = e.expression; propertyName = e.name.text; } - if (_enumType !== currentType) { + var current = expression; + while (current) { + if (current.kind === 65) { + break; + } + else if (current.kind === 155) { + current = current.expression; + } + else { + return undefined; + } + } + enumType = checkExpression(expression); + if (!(enumType.symbol && (enumType.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(_enumType, propertyName); + var property = getPropertyOfObjectType(enumType, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -15956,7 +16810,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -15975,7 +16829,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 199) { + if (declaration.kind !== 201) { return false; } var enumDeclaration = declaration; @@ -15998,7 +16852,7 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 196 || (declaration.kind === 195 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 198 || (declaration.kind === 197 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -16006,7 +16860,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarModifiers(node)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -16041,7 +16895,7 @@ var ts; checkSourceElement(node.body); } function getFirstIdentifier(node) { - while (node.kind === 125) { + while (node.kind === 126) { node = node.left; } return node; @@ -16052,9 +16906,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 201 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 221 && !inAmbientExternalModule) { - error(moduleName, node.kind === 210 ? + var inAmbientExternalModule = node.parent.kind === 203 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 224 && !inAmbientExternalModule) { + error(moduleName, node.kind === 212 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module : ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); return false; @@ -16073,7 +16927,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 212 ? + var message = node.kind === 214 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -16086,7 +16940,7 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -16096,7 +16950,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { checkImportBinding(importClause.namedBindings); } else { @@ -16107,7 +16961,7 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -16127,15 +16981,30 @@ var ts; } } } + else { + if (languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + } + } } } function checkExportDeclaration(node) { - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); + var inAmbientExternalModule = node.parent.kind === 203 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 224 && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + } + } + else { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, ts.Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } } } } @@ -16146,67 +17015,58 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 221 ? node.parent : node.parent.parent; - if (container.kind === 200 && container.name.kind === 64) { + var container = node.parent.kind === 224 ? node.parent : node.parent.parent; + if (container.kind === 202 && container.name.kind === 65) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); return; } - if (!checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 64) { - markExportAsReferenced(node); + if (node.expression) { + if (node.expression.kind === 65) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } } - else { - checkExpressionCached(node.expression); + if (node.type) { + checkSourceElement(node.type); + if (!ts.isInAmbientContext(node)) { + grammarErrorOnFirstToken(node.type, ts.Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration); + } } checkExternalModuleExports(container); + if (node.isExportEquals && languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } } function getModuleStatements(node) { - if (node.kind === 221) { + if (node.kind === 224) { return node.statements; } - if (node.kind === 200 && node.body.kind === 201) { + if (node.kind === 202 && node.body.kind === 203) { return node.body.statements; } return emptyArray; } function hasExportedMembers(moduleSymbol) { - var declarations = moduleSymbol.declarations; - for (var _i = 0, _n = declarations.length; _i < _n; _i++) { - var current = declarations[_i]; - var statements = getModuleStatements(current); - for (var _a = 0, _b = statements.length; _a < _b; _a++) { - var node = statements[_a]; - if (node.kind === 210) { - var exportClause = node.exportClause; - if (!exportClause) { - return true; - } - var specifiers = exportClause.elements; - for (var _c = 0, _d = specifiers.length; _c < _d; _c++) { - var specifier = specifiers[_c]; - if (!(specifier.propertyName && specifier.name && specifier.name.text === "default")) { - return true; - } - } - } - else if (node.kind !== 209 && node.flags & 1 && !(node.flags & 256)) { - return true; - } + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; } } + return false; } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - if (hasExportedMembers(moduleSymbol)) { - var declaration = getDeclarationOfAliasSymbol(defaultSymbol) || defaultSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } + var exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } links.exportsChecked = true; } @@ -16215,162 +17075,162 @@ var ts; if (!node) return; switch (node.kind) { - case 127: - return checkTypeParameter(node); case 128: - return checkParameter(node); - case 130: + return checkTypeParameter(node); case 129: - return checkPropertyDeclaration(node); - case 140: - case 141: - case 136: - case 137: - return checkSignatureDeclaration(node); - case 138: - return checkSignatureDeclaration(node); + return checkParameter(node); case 132: case 131: - return checkMethodDeclaration(node); - case 133: - return checkConstructorDeclaration(node); - case 134: - case 135: - return checkAccessorDeclaration(node); - case 139: - return checkTypeReference(node); + return checkPropertyDeclaration(node); case 142: - return checkTypeQuery(node); case 143: - return checkTypeLiteral(node); + case 138: + case 139: + return checkSignatureDeclaration(node); + case 140: + return checkSignatureDeclaration(node); + case 134: + case 133: + return checkMethodDeclaration(node); + case 135: + return checkConstructorDeclaration(node); + case 136: + case 137: + return checkAccessorDeclaration(node); + case 141: + return checkTypeReference(node); case 144: - return checkArrayType(node); + return checkTypeQuery(node); case 145: - return checkTupleType(node); + return checkTypeLiteral(node); case 146: - return checkUnionType(node); + return checkArrayType(node); case 147: + return checkTupleType(node); + case 148: + return checkUnionType(node); + case 149: return checkSourceElement(node.type); - case 195: - return checkFunctionDeclaration(node); - case 174: - case 201: - return checkBlock(node); - case 175: - return checkVariableStatement(node); - case 177: - return checkExpressionStatement(node); - case 178: - return checkIfStatement(node); - case 179: - return checkDoStatement(node); - case 180: - return checkWhileStatement(node); - case 181: - return checkForStatement(node); - case 182: - return checkForInStatement(node); - case 183: - return checkForOfStatement(node); - case 184: - case 185: - return checkBreakOrContinueStatement(node); - case 186: - return checkReturnStatement(node); - case 187: - return checkWithStatement(node); - case 188: - return checkSwitchStatement(node); - case 189: - return checkLabeledStatement(node); - case 190: - return checkThrowStatement(node); - case 191: - return checkTryStatement(node); - case 193: - return checkVariableDeclaration(node); - case 150: - return checkBindingElement(node); - case 196: - return checkClassDeclaration(node); case 197: - return checkInterfaceDeclaration(node); - case 198: - return checkTypeAliasDeclaration(node); - case 199: - return checkEnumDeclaration(node); - case 200: - return checkModuleDeclaration(node); - case 204: - return checkImportDeclaration(node); - case 203: - return checkImportEqualsDeclaration(node); - case 210: - return checkExportDeclaration(node); - case 209: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 176: - checkGrammarStatementInAmbientContext(node); - return; + case 203: + return checkBlock(node); + case 177: + return checkVariableStatement(node); + case 179: + return checkExpressionStatement(node); + case 180: + return checkIfStatement(node); + case 181: + return checkDoStatement(node); + case 182: + return checkWhileStatement(node); + case 183: + return checkForStatement(node); + case 184: + return checkForInStatement(node); + case 185: + return checkForOfStatement(node); + case 186: + case 187: + return checkBreakOrContinueStatement(node); + case 188: + return checkReturnStatement(node); + case 189: + return checkWithStatement(node); + case 190: + return checkSwitchStatement(node); + case 191: + return checkLabeledStatement(node); case 192: + return checkThrowStatement(node); + case 193: + return checkTryStatement(node); + case 195: + return checkVariableDeclaration(node); + case 152: + return checkBindingElement(node); + case 198: + return checkClassDeclaration(node); + case 199: + return checkInterfaceDeclaration(node); + case 200: + return checkTypeAliasDeclaration(node); + case 201: + return checkEnumDeclaration(node); + case 202: + return checkModuleDeclaration(node); + case 206: + return checkImportDeclaration(node); + case 205: + return checkImportEqualsDeclaration(node); + case 212: + return checkExportDeclaration(node); + case 211: + return checkExportAssignment(node); + case 178: checkGrammarStatementInAmbientContext(node); return; + case 194: + checkGrammarStatementInAmbientContext(node); + return; + case 215: + return checkMissingDeclaration(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 160: - case 161: + case 162: + case 163: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 132: - case 131: + case 134: + case 133: ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 133: - case 134: case 135: - case 195: + case 136: + case 137: + case 197: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 187: + case 189: checkFunctionExpressionBodies(node.expression); break; - case 128: - case 130: case 129: - case 148: - case 149: + case 132: + case 131: case 150: case 151: case 152: - case 218: case 153: case 154: + case 221: case 155: case 156: case 157: - case 169: - case 173: case 158: case 159: - case 163: - case 164: - case 162: + case 171: + case 175: + case 160: + case 161: case 165: case 166: + case 164: case 167: case 168: - case 171: - case 174: - case 201: - case 175: + case 169: + case 170: + case 173: + case 176: + case 203: case 177: - case 178: case 179: case 180: case 181: @@ -16379,21 +17239,23 @@ var ts; case 184: case 185: case 186: + case 187: case 188: - case 202: - case 214: - case 215: - case 189: case 190: - case 191: + case 204: case 217: + case 218: + case 191: + case 192: case 193: - case 194: - case 196: - case 199: case 220: - case 209: - case 221: + case 195: + case 196: + case 198: + case 201: + case 223: + case 211: + case 224: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -16421,6 +17283,9 @@ var ts; if (emitExtends) { links.flags |= 8; } + if (emitDecorate) { + links.flags |= 512; + } links.flags |= 1; } } @@ -16445,7 +17310,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 187 && node.parent.statement === node) { + if (node.parent.kind === 189 && node.parent.statement === node) { return true; } node = node.parent; @@ -16456,6 +17321,44 @@ var ts; function getSymbolsInScope(location, meaning) { var symbols = {}; var memberFlags = 0; + if (isInsideWithStatementBody(location)) { + return []; + } + populateSymbols(); + return symbolsToArray(symbols); + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + switch (location.kind) { + case 224: + if (!ts.isExternalModule(location)) { + break; + } + case 202: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); + break; + case 201: + copySymbols(getSymbolOfNode(location).exports, meaning & 8); + break; + case 198: + case 199: + if (!(memberFlags & 128)) { + copySymbols(getSymbolOfNode(location).members, meaning & 793056); + } + break; + case 162: + if (location.name) { + copySymbol(location.symbol, meaning); + } + break; + } + memberFlags = location.flags; + location = location.parent; + } + copySymbols(globals, meaning); + } function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; @@ -16481,22 +17384,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 221: + case 224: if (!ts.isExternalModule(location)) break; - case 200: + case 202: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 199: + case 201: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 196: - case 197: + case 198: + case 199: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 160: + case 162: if (location.name) { copySymbol(location.symbol, meaning); } @@ -16506,97 +17409,97 @@ var ts; location = location.parent; } copySymbols(globals, meaning); - return ts.mapToArray(symbols); + return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 64 && + return name.kind == 65 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 127: - case 196: - case 197: + case 128: case 198: case 199: + case 200: + case 201: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 125) + while (node.parent && node.parent.kind === 126) node = node.parent; - return node.parent && node.parent.kind === 139; + return node.parent && node.parent.kind === 141; } function isTypeNode(node) { - if (139 <= node.kind && node.kind <= 147) { + if (141 <= node.kind && node.kind <= 149) { return true; } switch (node.kind) { - case 111: - case 118: - case 120: case 112: + case 119: case 121: + case 113: + case 122: return true; - case 98: - return node.parent.kind !== 164; + case 99: + return node.parent.kind !== 166; case 8: - return node.parent.kind === 128; - case 64: - if (node.parent.kind === 125 && node.parent.right === node) { + return node.parent.kind === 129; + case 65: + if (node.parent.kind === 126 && node.parent.right === node) { node = node.parent; } - case 125: - ts.Debug.assert(node.kind === 64 || node.kind === 125, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); - var _parent = node.parent; - if (_parent.kind === 142) { + case 126: + ts.Debug.assert(node.kind === 65 || node.kind === 126, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + var parent_5 = node.parent; + if (parent_5.kind === 144) { return false; } - if (139 <= _parent.kind && _parent.kind <= 147) { + if (141 <= parent_5.kind && parent_5.kind <= 149) { return true; } - switch (_parent.kind) { - case 127: - return node === _parent.constraint; - case 130: - case 129: + switch (parent_5.kind) { case 128: - case 193: - return node === _parent.type; - case 195: - case 160: - case 161: - case 133: + return node === parent_5.constraint; case 132: case 131: - case 134: + case 129: + case 195: + return node === parent_5.type; + case 197: + case 162: + case 163: case 135: - return node === _parent.type; + case 134: + case 133: case 136: case 137: + return node === parent_5.type; case 138: - return node === _parent.type; - case 158: - return node === _parent.type; - case 155: - case 156: - return _parent.typeArguments && ts.indexOf(_parent.typeArguments, node) >= 0; + case 139: + case 140: + return node === parent_5.type; + case 160: + return node === parent_5.type; case 157: + case 158: + return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; + case 159: return false; } } return false; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 125) { + while (nodeOnRightSide.parent.kind === 126) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 203) { + if (nodeOnRightSide.parent.kind === 205) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209) { + if (nodeOnRightSide.parent.kind === 211) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -16605,17 +17508,17 @@ var ts; return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 125 && node.parent.right === node) || - (node.parent.kind === 153 && node.parent.name === node); + return (node.parent.kind === 126 && node.parent.right === node) || + (node.parent.kind === 155 && node.parent.name === node); } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 209) { + if (entityName.parent.kind === 211) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 153) { + if (entityName.kind !== 155) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -16627,29 +17530,29 @@ var ts; if (ts.getFullWidth(entityName) === 0) { return undefined; } - if (entityName.kind === 64) { + if (entityName.kind === 65) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 153) { + else if (entityName.kind === 155) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 125) { - var _symbol = getNodeLinks(entityName).resolvedSymbol; - if (!_symbol) { + else if (entityName.kind === 126) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { checkQualifiedName(entityName); } return getNodeLinks(entityName).resolvedSymbol; } } else if (isTypeReferenceIdentifier(entityName)) { - var _meaning = entityName.parent.kind === 139 ? 793056 : 1536; - _meaning |= 8388608; - return resolveEntityName(entityName, _meaning); + var meaning = entityName.parent.kind === 141 ? 793056 : 1536; + meaning |= 8388608; + return resolveEntityName(entityName, meaning); } return undefined; } @@ -16660,23 +17563,23 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 64 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 209 + if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 211 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { - case 64: - case 153: - case 125: + case 65: + case 155: + case 126: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 92: - case 90: + case 93: + case 91: var type = checkExpression(node); return type.symbol; - case 113: + case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 133) { + if (constructorDeclaration && constructorDeclaration.kind === 135) { return constructorDeclaration.parent.symbol; } return undefined; @@ -16684,12 +17587,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 204 || node.parent.kind === 210) && + ((node.parent.kind === 206 || node.parent.kind === 212) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 154 && node.parent.argumentExpression === node) { + if (node.parent.kind == 156 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -16703,7 +17606,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 219) { + if (location && location.kind === 222) { return resolveEntityName(location.name, 107455); } return undefined; @@ -16723,21 +17626,21 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var _symbol = getSymbolInfo(node); - return _symbol && getDeclaredTypeOfSymbol(_symbol); + var symbol = getSymbolInfo(node); + return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - var _symbol_1 = getSymbolOfNode(node); - return getTypeOfSymbol(_symbol_1); + var symbol = getSymbolOfNode(node); + return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var _symbol_2 = getSymbolInfo(node); - return _symbol_2 && getTypeOfSymbol(_symbol_2); + var symbol = getSymbolInfo(node); + return symbol && getTypeOfSymbol(symbol); } if (isInRightSideOfImportOrExportAssignment(node)) { - var _symbol_3 = getSymbolInfo(node); - var declaredType = _symbol_3 && getDeclaredTypeOfSymbol(_symbol_3); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(_symbol_3); + var symbol = getSymbolInfo(node); + var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); + return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } return unknownType; } @@ -16762,9 +17665,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols = []; - var _name = symbol.name; + var name_10 = symbol.name; ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { - symbols.push(getPropertyOfType(t, _name)); + symbols.push(getPropertyOfType(t, name_10)); }); return symbols; } @@ -16777,160 +17680,73 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 221; + return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 224; } - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; + function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { + if (languageVersion >= 2) { + return undefined; } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } + var node = getDeclarationOfAliasSymbol(symbol); + if (node) { + if (node.kind === 207) { + return getGeneratedNameForNode(node.parent) + ".default"; } - } - return true; - } - function getGeneratedNamesForSourceFile(sourceFile) { - var links = getNodeLinks(sourceFile); - var generatedNames = links.generatedNames; - if (!generatedNames) { - generatedNames = links.generatedNames = {}; - generateNames(sourceFile); - } - return generatedNames; - function generateNames(node) { - switch (node.kind) { - case 195: - case 196: - generateNameForFunctionOrClassDeclaration(node); - break; - case 200: - generateNameForModuleOrEnum(node); - generateNames(node.body); - break; - case 199: - generateNameForModuleOrEnum(node); - break; - case 204: - generateNameForImportDeclaration(node); - break; - case 210: - generateNameForExportDeclaration(node); - break; - case 209: - generateNameForExportAssignment(node); - break; - case 221: - case 201: - ts.forEach(node.statements, generateNames); - break; - } - } - function isExistingName(name) { - return ts.hasProperty(globals, name) || ts.hasProperty(sourceFile.identifiers, name) || ts.hasProperty(generatedNames, name); - } - function makeUniqueName(baseName) { - var _name = ts.generateUniqueName(baseName, isExistingName); - return generatedNames[_name] = _name; - } - function assignGeneratedName(node, name) { - getNodeLinks(node).generatedName = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } - function generateNameForModuleOrEnum(node) { - if (node.name.kind === 64) { - var _name = node.name.text; - assignGeneratedName(node, isUniqueLocalName(_name, node) ? _name : makeUniqueName(_name)); - } - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); - } - function generateNameForImportDeclaration(node) { - if (node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 207) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression.kind !== 64) { - assignGeneratedName(node, makeUniqueName("default")); + if (node.kind === 210) { + var moduleName = getGeneratedNameForNode(node.parent.parent.parent); + var propertyName = node.propertyName || node.name; + return moduleName + "." + ts.unescapeIdentifier(propertyName.text); } } } - function getGeneratedNameForNode(node) { - var links = getNodeLinks(node); - if (!links.generatedName) { - getGeneratedNamesForSourceFile(getSourceFile(node)); - } - return links.generatedName; - } - function getLocalNameOfContainer(container) { - return getGeneratedNameForNode(container); - } - function getLocalNameForImportDeclaration(node) { - return getGeneratedNameForNode(node); - } - function getAliasNameSubstitution(symbol) { - var declaration = getDeclarationOfAliasSymbol(symbol); - if (declaration && declaration.kind === 208) { - var moduleName = getGeneratedNameForNode(declaration.parent.parent.parent); - var propertyName = declaration.propertyName || declaration.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - function getExportNameSubstitution(symbol, location) { + function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { if (isExternalModuleSymbol(symbol.parent)) { + if (languageVersion >= 2) { + return undefined; + } return "exports." + ts.unescapeIdentifier(symbol.name); } var node = location; var containerSymbol = getParentOfSymbol(symbol); while (node) { - if ((node.kind === 200 || node.kind === 199) && getSymbolOfNode(node) === containerSymbol) { + if ((node.kind === 202 || node.kind === 201) && getSymbolOfNode(node) === containerSymbol) { return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); } node = node.parent; } } - function getExpressionNameSubstitution(node) { - var symbol = getNodeLinks(node).resolvedSymbol; + function getExpressionNameSubstitution(node, getGeneratedNameForNode) { + var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); if (symbol) { if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent); + return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); } var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (symbol !== exportSymbol && !(exportSymbol.flags & 944)) { - return getExportNameSubstitution(exportSymbol, node.parent); + return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); } if (symbol.flags & 8388608) { - return getAliasNameSubstitution(symbol); + return getAliasNameSubstitution(symbol, getGeneratedNameForNode); } } } - function hasExportDefaultValue(node) { - var symbol = getResolvedExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbol !== unknownSymbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol); + function isValueAliasDeclaration(node) { + switch (node.kind) { + case 205: + case 207: + case 208: + case 210: + case 214: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 212: + var exportClause = node.exportClause; + return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 211: + return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 221 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 224 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } return isAliasResolvedToValue(getSymbolOfNode(node)); @@ -16942,14 +17758,17 @@ var ts; function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; } - function isReferencedAliasDeclaration(node) { - if (isAliasSymbolDeclaration(node)) { + function isReferencedAliasDeclaration(node, checkChildren) { + if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { return true; } } - return ts.forEachChild(node, isReferencedAliasDeclaration); + if (checkChildren) { + return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + } + return false; } function isImplementationOfOverload(node) { if (ts.nodeIsPresent(node.body)) { @@ -16968,15 +17787,13 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 220) { + if (node.kind === 223) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8)) { - var declaration = symbol.valueDeclaration; - var constantValue; - if (declaration.kind === 220) { - return getEnumMemberValue(declaration); + if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); } } return undefined; @@ -16992,42 +17809,48 @@ var ts; var signature = getSignatureFromDeclaration(signatureDeclaration); getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } - function isUnknownIdentifier(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "isUnknownIdentifier called with a synthesized location"); - return !resolveName(location, name, 107455, undefined, undefined) && - !ts.hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name); + function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function hasGlobalName(name) { + return ts.hasProperty(globals, name); + } + function resolvesToSomeValue(location, name) { + ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); + return !!resolveName(location, name, 107455, undefined, undefined); } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - if (n.parent.kind === 153 && - n.parent.name === n) { - return undefined; - } - if (n.parent.kind === 150 && - n.parent.propertyName === n) { - return undefined; - } - var declarationSymbol = (n.parent.kind === 193 && n.parent.name === n) || - n.parent.kind === 150 - ? getSymbolOfNode(n.parent) - : undefined; - var symbol = declarationSymbol || + var isVariableDeclarationOrBindingElement = n.parent.kind === 152 || (n.parent.kind === 195 && n.parent.name === n); + var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 217; + symbol.valueDeclaration.parent.kind !== 220; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; } return undefined; } + function instantiateSingleCallFunctionType(functionType, typeArguments) { + if (functionType === unknownType) { + return unknownType; + } + var signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } function createResolver() { return { - getGeneratedNameForNode: getGeneratedNameForNode, getExpressionNameSubstitution: getExpressionNameSubstitution, - hasExportDefaultValue: hasExportDefaultValue, + isValueAliasDeclaration: isValueAliasDeclaration, + hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, getNodeCheckFlags: getNodeCheckFlags, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, @@ -17035,10 +17858,12 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression: writeTypeOfExpression, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - isUnknownIdentifier: isUnknownIdentifier, + resolvesToSomeValue: resolvesToSomeValue, + collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId }; } @@ -17063,6 +17888,11 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); + globalClassDecoratorType = getGlobalType("ClassDecorator"); + globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); + globalMethodDecoratorType = getGlobalType("MethodDecorator"); + globalParameterDecoratorType = getGlobalType("ParameterDecorator"); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -17076,28 +17906,46 @@ var ts; } anyArrayType = createArrayType(anyType); } + function checkGrammarDecorators(node) { + if (!node.decorators) { + return false; + } + if (!ts.nodeCanBeDecorated(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + else if (languageVersion < 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (node.kind === 136 || node.kind === 137) { + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnNode(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } function checkGrammarModifiers(node) { switch (node.kind) { - case 134: + case 136: + case 137: case 135: - case 133: - case 130: - case 129: case 132: case 131: - case 138: - case 196: + case 134: + case 133: + case 140: + case 198: + case 199: + case 202: + case 201: + case 177: case 197: case 200: - case 199: - case 175: - case 195: - case 198: - case 204: - case 203: - case 210: - case 209: - case 128: + case 206: + case 205: + case 212: + case 211: + case 129: break; default: return false; @@ -17110,14 +17958,14 @@ var ts; for (var _i = 0, _a = node.modifiers, _n = _a.length; _i < _n; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 109: case 108: case 107: - case 106: var text = void 0; - if (modifier.kind === 108) { + if (modifier.kind === 109) { text = "public"; } - else if (modifier.kind === 107) { + else if (modifier.kind === 108) { text = "protected"; lastProtected = modifier; } @@ -17131,50 +17979,50 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 201 || node.parent.kind === 221) { + else if (node.parent.kind === 203 || node.parent.kind === 224) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); break; - case 109: + case 110: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 201 || node.parent.kind === 221) { + else if (node.parent.kind === 203 || node.parent.kind === 224) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; lastStatic = modifier; break; - case 77: + case 78: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 114: + case 115: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 128) { + else if (node.kind === 129) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 201) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 203) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -17182,7 +18030,7 @@ var ts; break; } } - if (node.kind === 133) { + if (node.kind === 135) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -17193,13 +18041,13 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 204 || node.kind === 203) && flags & 2) { + else if ((node.kind === 206 || node.kind === 205) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 197 && flags & 2) { + else if (node.kind === 199 && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } - else if (node.kind === 128 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 129 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -17211,15 +18059,14 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters) { + function checkGrammarTypeParameterList(node, typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } if (typeParameters && typeParameters.length === 0) { var start = typeParameters.pos - "<".length; - var sourceFile = ts.getSourceFileOfNode(node); - var end = ts.skipTrivia(sourceFile.text, typeParameters.end) + ">".length; - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); + var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } } function checkGrammarParameterList(parameters) { @@ -17255,7 +18102,20 @@ var ts; } } function checkGrammarFunctionLikeDeclaration(node) { - return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); + var file = ts.getSourceFileOfNode(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + } + function checkGrammarArrowFunction(node, file) { + if (node.kind === 163) { + var arrowFunction = node; + var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + if (startLine !== endLine) { + return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); + } + } + return false; } function checkGrammarIndexSignatureParameters(node) { var parameter = node.parameters[0]; @@ -17282,7 +18142,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 120 && parameter.type.kind !== 118) { + if (parameter.type.kind !== 121 && parameter.type.kind !== 119) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -17295,7 +18155,7 @@ var ts; } } function checkGrammarIndexSignature(node) { - checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); } function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { if (typeArguments && typeArguments.length === 0) { @@ -17314,7 +18174,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, _n = arguments.length; _i < _n; _i++) { var arg = arguments[_i]; - if (arg.kind === 172) { + if (arg.kind === 174) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -17338,10 +18198,10 @@ var ts; function checkGrammarClassDeclarationHeritageClauses(node) { var seenExtendsClause = false; var seenImplementsClause = false; - if (!checkGrammarModifiers(node) && node.heritageClauses) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses, _n = _a.length; _i < _n; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 78) { + if (heritageClause.token === 79) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -17354,7 +18214,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -17369,14 +18229,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses, _n = _a.length; _i < _n; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 78) { + if (heritageClause.token === 79) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -17385,11 +18245,11 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 126) { + if (node.kind !== 127) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 167 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 169 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -17415,52 +18275,52 @@ var ts; var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties, _n = _a.length; _i < _n; _i++) { var prop = _a[_i]; - var _name = prop.name; - if (prop.kind === 172 || - _name.kind === 126) { - checkGrammarComputedPropertyName(_name); + var name_11 = prop.name; + if (prop.kind === 174 || + name_11.kind === 127) { + checkGrammarComputedPropertyName(name_11); continue; } var currentKind = void 0; - if (prop.kind === 218 || prop.kind === 219) { + if (prop.kind === 221 || prop.kind === 222) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (_name.kind === 7) { - checkGrammarNumbericLiteral(_name); + if (name_11.kind === 7) { + checkGrammarNumbericLiteral(name_11); } currentKind = Property; } - else if (prop.kind === 132) { + else if (prop.kind === 134) { currentKind = Property; } - else if (prop.kind === 134) { + else if (prop.kind === 136) { currentKind = GetAccessor; } - else if (prop.kind === 135) { + else if (prop.kind === 137) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, _name.text)) { - seen[_name.text] = currentKind; + if (!ts.hasProperty(seen, name_11.text)) { + seen[name_11.text] = currentKind; } else { - var existingKind = seen[_name.text]; + var existingKind = seen[name_11.text]; if (currentKind === Property && existingKind === Property) { if (inStrictMode) { - grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); } } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[_name.text] = currentKind | existingKind; + seen[name_11.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(_name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -17469,27 +18329,27 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 194) { + if (forInOrOfStatement.initializer.kind === 196) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var _diagnostic = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; - return grammarErrorOnNode(firstDeclaration.name, _diagnostic); + return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var _diagnostic_1 = forInOrOfStatement.kind === 182 + var diagnostic = forInOrOfStatement.kind === 184 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; - return grammarErrorOnNode(firstDeclaration, _diagnostic_1); + return grammarErrorOnNode(firstDeclaration, diagnostic); } } } @@ -17509,10 +18369,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 134 && accessor.parameters.length) { + else if (kind === 136 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 135) { + else if (kind === 137) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -17537,7 +18397,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 126 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 127 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -17547,7 +18407,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 152) { + if (node.parent.kind === 154) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -17555,7 +18415,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 196) { + if (node.parent.kind === 198) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -17566,22 +18426,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 197) { + else if (node.parent.kind === 199) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 143) { + else if (node.parent.kind === 145) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 183: + case 184: + case 185: case 181: case 182: - case 183: - case 179: - case 180: return true; - case 189: + case 191: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -17593,9 +18453,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 189: + case 191: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 184 + var isMisplacedContinueLabel = node.kind === 186 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -17603,8 +18463,8 @@ var ts; return false; } break; - case 188: - if (node.kind === 185 && !node.label) { + case 190: + if (node.kind === 187 && !node.label) { return false; } break; @@ -17617,16 +18477,16 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 185 + var message = node.kind === 187 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var _message = node.kind === 185 + var message = node.kind === 187 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, _message); + return grammarErrorOnNode(node, message); } } function checkGrammarBindingElement(node) { @@ -17642,7 +18502,7 @@ var ts; return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 182 && node.parent.parent.kind !== 183) { + if (node.parent.parent.kind !== 184 && node.parent.parent.kind !== 185) { if (ts.isInAmbientContext(node)) { if (ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); @@ -17666,7 +18526,7 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 64) { + if (name.kind === 65) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -17690,15 +18550,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 178: - case 179: case 180: - case 187: case 181: case 182: - case 183: - return false; case 189: + case 183: + case 184: + case 185: + return false; + case 191: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -17714,7 +18574,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 165) { + if (expression.kind === 167) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -17733,7 +18593,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members, _n = _a.length; _i < _n; _i++) { var node = _a[_i]; - if (node.name.kind === 126) { + if (node.name.kind === 127) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -17776,7 +18636,7 @@ var ts; } } function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 64) { + if (name && name.kind === 65) { var identifier = name; if (contextNode && (contextNode.parserContextFlags & 1) && ts.isEvalOrArgumentsIdentifier(identifier)) { var nameText = ts.declarationNameToString(identifier); @@ -17795,18 +18655,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 196) { + if (node.parent.kind === 198) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 197) { + else if (node.parent.kind === 199) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 143) { + else if (node.parent.kind === 145) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -17816,12 +18676,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 197 || - node.kind === 204 || - node.kind === 203 || - node.kind === 210 || - node.kind === 209 || - (node.flags & 2)) { + if (node.kind === 199 || + node.kind === 206 || + node.kind === 205 || + node.kind === 212 || + node.kind === 211 || + (node.flags & 2) || + (node.flags & (1 | 256))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -17829,7 +18690,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements, _n = _a.length; _i < _n; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 175) { + if (ts.isDeclaration(decl) || decl.kind === 177) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -17848,10 +18709,10 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 174 || node.parent.kind === 201 || node.parent.kind === 221) { - var _links = getNodeLinks(node.parent); - if (!_links.hasReportedStatementInAmbientContext) { - return _links.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + if (node.parent.kind === 176 || node.parent.kind === 203 || node.parent.kind === 224) { + var links_1 = getNodeLinks(node.parent); + if (!links_1.hasReportedStatementInAmbientContext) { + return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } else { @@ -17881,251 +18742,16 @@ var ts; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); +/// var ts; (function (ts) { - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!ts.isDeclarationFile(sourceFile)) { - if ((ts.isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - return true; - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(ts.getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - var lineCount = ts.getLineStarts(currentSourceFile).length; - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : ts.getStartPositionOfLine(currentLine + 1, currentSourceFile); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(ts.getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 133 && ts.nodeIsPresent(member.body)) { - return member; - } - }); - } - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var getAccessor; - var setAccessor; - if (ts.hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 134) { - getAccessor = accessor; - } - else if (accessor.kind === 135) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 134 || member.kind === 135) - && (member.flags & 128) === (accessor.flags & 128)) { - var memberName = ts.getPropertyNameForPropertyNameNode(member.name); - var accessorName = ts.getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 134 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 135 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); + function getDeclarationDiagnostics(host, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); @@ -18141,7 +18767,8 @@ var ts; var reportedDeclarationError = false; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; - var aliasDeclarationEmitInfo = []; + var moduleElementDeclarationEmitInfo = []; + var asynchronousSubModuleDeclarationEmitInfo; var referencePathsOutput = ""; if (root) { if (!compilerOptions.noResolve) { @@ -18149,25 +18776,38 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); if (referencedFile && ((referencedFile.flags & 2048) || - shouldEmitToOwnFile(referencedFile, compilerOptions) || + ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); - if (!isExternalModuleOrDeclarationFile(referencedFile)) { + if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { addedGlobalFileReference = true; } } }); } emitSourceFile(root); + if (moduleElementDeclarationEmitInfo.length) { + var oldWriter = writer; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.isVisible) { + ts.Debug.assert(aliasEmitInfo.node.kind === 206); + createAndSetNewTextWriterWithSymbolWriter(); + ts.Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } } else { var emittedReferencedFiles = []; ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { + if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { if (!compilerOptions.noResolve) { ts.forEach(sourceFile.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); - if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && + if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) { writeReferencePath(referencedFile); emittedReferencedFiles.push(referencedFile); @@ -18180,7 +18820,7 @@ var ts; } return { reportedDeclarationError: reportedDeclarationError, - aliasDeclarationEmitInfo: aliasDeclarationEmitInfo, + moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), referencePathsOutput: referencePathsOutput }; @@ -18199,17 +18839,17 @@ var ts; } } function createAndSetNewTextWriterWithSymbolWriter() { - var _writer = createTextWriter(newLine); - _writer.trackSymbol = trackSymbol; - _writer.writeKeyword = _writer.write; - _writer.writeOperator = _writer.write; - _writer.writePunctuation = _writer.write; - _writer.writeSpace = _writer.write; - _writer.writeStringLiteral = _writer.writeLiteral; - _writer.writeParameter = _writer.write; - _writer.writeSymbol = _writer.write; - setWriter(_writer); - return _writer; + var writer = ts.createTextWriter(newLine); + writer.trackSymbol = trackSymbol; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + setWriter(writer); + return writer; } function setWriter(newWriter) { writer = newWriter; @@ -18219,17 +18859,43 @@ var ts; increaseIndent = newWriter.increaseIndent; decreaseIndent = newWriter.decreaseIndent; } - function writeAsychronousImportEqualsDeclarations(importEqualsDeclarations) { + function writeAsynchronousModuleElements(nodes) { var oldWriter = writer; - ts.forEach(importEqualsDeclarations, function (aliasToWrite) { - var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); - if (aliasEmitInfo) { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); + ts.forEach(nodes, function (declaration) { + var nodeToCheck; + if (declaration.kind === 195) { + nodeToCheck = declaration.parent.parent; + } + else if (declaration.kind === 209 || declaration.kind === 210 || declaration.kind === 207) { + ts.Debug.fail("We should be getting ImportDeclaration instead to write"); + } + else { + nodeToCheck = declaration; + } + var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + } + if (moduleElementEmitInfo) { + if (moduleElementEmitInfo.node.kind === 206) { + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + if (nodeToCheck.kind === 202) { + ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === 202) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); } - writeImportEqualsDeclaration(aliasToWrite); - aliasEmitInfo.asynchronousOutput = writer.getText(); } }); setWriter(oldWriter); @@ -18237,7 +18903,7 @@ var ts; function handleSymbolAccessibilityError(symbolAccesibilityResult) { if (symbolAccesibilityResult.accessibility === 0) { if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportEqualsDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); } } else { @@ -18282,25 +18948,27 @@ var ts; emit(node); } } - function emitSeparatedList(nodes, separator, eachNodeEmitFn) { + function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var node = nodes[_i]; - if (currentWriterPos !== writer.getTextPos()) { - write(separator); + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); } } - function emitCommaList(nodes, eachNodeEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn); + function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); } function writeJsDocComments(declaration) { if (declaration) { var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -18309,44 +18977,44 @@ var ts; } function emitType(type) { switch (type.kind) { - case 111: - case 120: - case 118: case 112: case 121: - case 98: + case 119: + case 113: + case 122: + case 99: case 8: return writeTextOfNode(currentSourceFile, type); - case 139: - return emitTypeReference(type); - case 142: - return emitTypeQuery(type); - case 144: - return emitArrayType(type); - case 145: - return emitTupleType(type); - case 146: - return emitUnionType(type); - case 147: - return emitParenType(type); - case 140: case 141: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 144: + return emitTypeQuery(type); + case 146: + return emitArrayType(type); + case 147: + return emitTupleType(type); + case 148: + return emitUnionType(type); + case 149: + return emitParenType(type); + case 142: case 143: + return emitSignatureDeclarationWithJsDocComments(type); + case 145: return emitTypeLiteral(type); - case 64: + case 65: return emitEntityName(type); - case 125: + case 126: return emitEntityName(type); default: ts.Debug.fail("Unknown type annotation: " + type.kind); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 203 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 205 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { - if (entityName.kind === 64) { + if (entityName.kind === 65) { writeTextOfNode(currentSourceFile, entityName); } else { @@ -18404,16 +19072,100 @@ var ts; } function emitExportAssignment(node) { write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); + if (node.expression.kind === 65) { + writeTextOfNode(currentSourceFile, node.expression); + } + else { + write(": "); + if (node.type) { + emitType(node.type); + } + else { + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + } + } write(";"); writeLine(); + if (node.expression.kind === 65) { + var nodes = resolver.collectLinkedAliases(node.expression); + writeAsynchronousModuleElements(nodes); + } + function getDefaultExportAccessibilityDiagnostic(diagnostic) { + return { + diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + function isModuleElementVisible(node) { + return resolver.isDeclarationVisible(node); + } + function emitModuleElement(node, isModuleElementVisible) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + else if (node.kind === 205 || + (node.parent.kind === 224 && ts.isExternalModule(currentSourceFile))) { + var isVisible; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 224) { + asynchronousSubModuleDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + else { + if (node.kind === 206) { + var importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + } + } + function writeModuleElement(node) { + switch (node.kind) { + case 197: + return writeFunctionDeclaration(node); + case 177: + return writeVariableStatement(node); + case 199: + return writeInterfaceDeclaration(node); + case 198: + return writeClassDeclaration(node); + case 200: + return writeTypeAliasDeclaration(node); + case 201: + return writeEnumDeclaration(node); + case 202: + return writeModuleDeclaration(node); + case 205: + return writeImportEqualsDeclaration(node); + case 206: + return writeImportDeclaration(node); + default: + ts.Debug.fail("Unknown symbol kind"); + } } function emitModuleElementDeclarationFlags(node) { if (node.parent === currentSourceFile) { if (node.flags & 1) { write("export "); } - if (node.kind !== 197) { + if (node.flags & 256) { + write("default "); + } + else if (node.kind !== 199) { write("declare "); } } @@ -18429,18 +19181,6 @@ var ts; write("static "); } } - function emitImportEqualsDeclaration(node) { - var nodeEmitInfo = { - declaration: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - hasWritten: resolver.isDeclarationVisible(node) - }; - aliasDeclarationEmitInfo.push(nodeEmitInfo); - if (nodeEmitInfo.hasWritten) { - writeImportEqualsDeclaration(node); - } - } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); if (node.flags & 1) { @@ -18467,40 +19207,110 @@ var ts; }; } } - function emitModuleDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("module "); - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 201) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); + function isVisibleNamedBinding(namedBindings) { + if (namedBindings) { + if (namedBindings.kind === 208) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; } } - function emitTypeAliasDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); + function writeImportDeclaration(node) { + if (!node.importClause && !(node.flags & 1)) { + return; } + emitJsDocComments(node); + if (node.flags & 1) { + write("export "); + } + write("import "); + if (node.importClause) { + var currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + write(", "); + } + if (node.importClause.namedBindings.kind === 208) { + write("* as "); + writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); + } + else { + write("{ "); + emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + function emitImportOrExportSpecifier(node) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + function emitExportSpecifier(node) { + emitImportOrExportSpecifier(node); + var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + writeAsynchronousModuleElements(nodes); + } + function emitExportDeclaration(node) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + function writeModuleDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("module "); + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== 203) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeTypeAliasDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -18509,23 +19319,21 @@ var ts; }; } } - function emitEnumDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); + function writeEnumDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isConst(node)) { + write("const "); } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); } function emitEnumMemberDeclaration(node) { emitJsDocComments(node); @@ -18539,7 +19347,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 132 && (node.parent.flags & 32); + return node.parent.kind === 134 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -18549,15 +19357,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 140 || - node.parent.kind === 141 || - (node.parent.parent && node.parent.parent.kind === 143)) { - ts.Debug.assert(node.parent.kind === 132 || - node.parent.kind === 131 || - node.parent.kind === 140 || - node.parent.kind === 141 || - node.parent.kind === 136 || - node.parent.kind === 137); + if (node.parent.kind === 142 || + node.parent.kind === 143 || + (node.parent.parent && node.parent.parent.kind === 145)) { + ts.Debug.assert(node.parent.kind === 134 || + node.parent.kind === 133 || + node.parent.kind === 142 || + node.parent.kind === 143 || + node.parent.kind === 138 || + node.parent.kind === 139); emitType(node.constraint); } else { @@ -18567,31 +19375,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 196: + case 198: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 197: + case 199: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 137: + case 139: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: + case 138: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 132: - case 131: + case 134: + case 133: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 196) { + else if (node.parent.parent.kind === 198) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 195: + case 197: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -18619,7 +19427,7 @@ var ts; emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 196) { + if (node.parent.parent.kind === 198) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -18635,7 +19443,7 @@ var ts; } } } - function emitClassDeclaration(node) { + function writeClassDeclaration(node) { function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { @@ -18645,49 +19453,45 @@ var ts; }); } } - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassBaseTypeNode(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); - } - emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("class "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); } + emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(ts.getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; } - function emitInterfaceDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } + function writeInterfaceDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; } function emitPropertyDeclaration(node) { if (ts.hasDynamicName(node)) { @@ -18700,54 +19504,83 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 193 || resolver.isDeclarationVisible(node)) { - writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 130 || node.kind === 129) && ts.hasQuestionToken(node)) { - write("?"); + if (node.kind !== 195 || resolver.isDeclarationVisible(node)) { + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); } - if ((node.kind === 130 || node.kind === 129) && node.parent.kind === 143) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + else { + writeTextOfNode(currentSourceFile, node.name); + if ((node.kind === 132 || node.kind === 131) && ts.hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === 132 || node.kind === 131) && node.parent.kind === 145) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & 32)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 193) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + if (node.kind === 195) { + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 130 || node.kind === 129) { + else if (node.kind === 132 || node.kind === 131) { if (node.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 196) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + else if (node.parent.kind === 198) { + return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, typeName: node.name } : undefined; } + function emitBindingPattern(bindingPattern) { + emitCommaList(bindingPattern.elements, emitBindingElement); + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + } + } + } } function emitTypeOfVariableDeclarationFromTypeLiteral(node) { if (node.type) { @@ -18755,30 +19588,30 @@ var ts; emitType(node.type); } } - function emitVariableStatement(node) { - var hasDeclarationWithEmit = ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - if (hasDeclarationWithEmit) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node.declarationList)) { - write("let "); - } - else if (ts.isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration); - write(";"); - writeLine(); + function isVariableStatementVisible(node) { + return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + } + function writeVariableStatement(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isLet(node.declarationList)) { + write("let "); } + else if (ts.isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); } function emitAccessorDeclaration(node) { if (ts.hasDynamicName(node)) { return; } - var accessors = getAllAccessorDeclarations(node.parent.members, node); + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); var accessorWithTypeAnnotation; if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); @@ -18789,7 +19622,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 134 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 136 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -18802,7 +19635,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 134 + return accessor.kind === 136 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -18811,7 +19644,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 135) { + if (accessorWithTypeAnnotation.kind === 137) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -18851,24 +19684,23 @@ var ts; } } } - function emitFunctionDeclaration(node) { + function writeFunctionDeclaration(node) { if (ts.hasDynamicName(node)) { return; } - if ((node.kind !== 195 || resolver.isDeclarationVisible(node)) && - !resolver.isImplementationOfOverload(node)) { + if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 195) { + if (node.kind === 197) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 132) { + else if (node.kind === 134) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 195) { + if (node.kind === 197) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 133) { + else if (node.kind === 135) { write("constructor"); } else { @@ -18885,11 +19717,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 137 || node.kind === 141) { + if (node.kind === 139 || node.kind === 143) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 138) { + if (node.kind === 140) { write("["); } else { @@ -18898,20 +19730,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 138) { + if (node.kind === 140) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 140 || node.kind === 141; - if (isFunctionTypeOrConstructorType || node.parent.kind === 143) { + var isFunctionTypeOrConstructorType = node.kind === 142 || node.kind === 143; + if (isFunctionTypeOrConstructorType || node.parent.kind === 145) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 133 && !(node.flags & 32)) { + else if (node.kind !== 135 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -18922,23 +19754,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 137: + case 139: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 136: + case 138: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 138: + case 140: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 132: - case 131: + case 134: + case 133: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -18946,7 +19778,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 196) { + else if (node.parent.kind === 198) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -18959,7 +19791,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 195: + case 197: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -18991,9 +19823,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 140 || - node.parent.kind === 141 || - node.parent.parent.kind === 143) { + if (node.parent.kind === 142 || + node.parent.kind === 143 || + node.parent.parent.kind === 145) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -19002,25 +19834,25 @@ var ts; function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 133: + case 135: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; - case 137: + case 139: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: + case 138: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 132: - case 131: + case 134: + case 133: if (node.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -19028,7 +19860,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 196) { + else if (node.parent.parent.kind === 198) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -19041,7 +19873,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 195: + case 197: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -19060,60 +19892,90 @@ var ts; } function emitNode(node) { switch (node.kind) { + case 197: + case 202: + case 205: + case 199: + case 198: + case 200: + case 201: + return emitModuleElement(node, isModuleElementVisible(node)); + case 177: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 206: + return emitModuleElement(node, !node.importClause); + case 212: + return emitExportDeclaration(node); + case 135: + case 134: case 133: - case 195: + return writeFunctionDeclaration(node); + case 139: + case 138: + case 140: + return emitSignatureDeclarationWithJsDocComments(node); + case 136: + case 137: + return emitAccessorDeclaration(node); case 132: case 131: - return emitFunctionDeclaration(node); - case 137: - case 136: - case 138: - return emitSignatureDeclarationWithJsDocComments(node); - case 134: - case 135: - return emitAccessorDeclaration(node); - case 175: - return emitVariableStatement(node); - case 130: - case 129: return emitPropertyDeclaration(node); - case 197: - return emitInterfaceDeclaration(node); - case 196: - return emitClassDeclaration(node); - case 198: - return emitTypeAliasDeclaration(node); - case 220: + case 223: return emitEnumMemberDeclaration(node); - case 199: - return emitEnumDeclaration(node); - case 200: - return emitModuleDeclaration(node); - case 203: - return emitImportEqualsDeclaration(node); - case 209: + case 211: return emitExportAssignment(node); - case 221: + case 224: return emitSourceFile(node); } } function writeReferencePath(referencedFile) { var declFileName = referencedFile.flags & 2048 ? referencedFile.fileName - : shouldEmitToOwnFile(referencedFile, compilerOptions) - ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") + : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) + ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } } - function getDeclarationDiagnostics(host, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; + function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { + var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + if (!emitDeclarationResult.reportedDeclarationError) { + var declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { + var appliedSyncOutputPos = 0; + var declarationOutput = ""; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return declarationOutput; + } } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + ts.writeDeclarationFile = writeDeclarationFile; +})(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + TempFlags[TempFlags["_n"] = 536870912] = "_n"; + })(TempFlags || (TempFlags = {})); function emitFiles(resolver, host, targetSourceFile) { var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; @@ -19122,8 +19984,8 @@ var ts; var newLine = host.getNewLine(); if (targetSourceFile === undefined) { ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, ".js"); + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -19132,8 +19994,8 @@ var ts; } } else { - if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -19146,8 +20008,26 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } function emitJavaScript(jsFilePath, root) { - var writer = createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var write = writer.write; var writeTextOfNode = writer.writeTextOfNode; var writeLine = writer.writeLine; @@ -19155,26 +20035,23 @@ var ts; var decreaseIndent = writer.decreaseIndent; var preserveNewLines = compilerOptions.preserveNewLines || false; var currentSourceFile; - var lastFrame; - var currentScopeNames; - var generatedBlockScopeNames; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var blockScopedVariableToGeneratedName; + var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; - var tempCount = 0; + var decorateEmitted = false; + var tempFlags = 0; var tempVariables; var tempParameters; var externalImports; var exportSpecifiers; - var exportDefault; + var exportEquals; + var hasExportStars; var writeEmittedFiles = writeJavaScriptFile; - var emitLeadingComments = compilerOptions.removeComments ? function (node) { } : emitLeadingDeclarationComments; - var emitTrailingComments = compilerOptions.removeComments ? function (node) { } : emitTrailingDeclarationComments; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfLocalPosition; var detachedCommentsInfo; - var emitDetachedComments = compilerOptions.removeComments ? function (node) { } : emitDetachedCommentsAtPosition; - var writeComment = writeCommentRange; - var emitNodeWithoutSourceMap = compilerOptions.removeComments ? emitNodeWithoutSourceMapWithoutComments : emitNodeWithoutSourceMapWithComments; + var writeComment = ts.writeCommentRange; var emit = emitNodeWithoutSourceMap; - var emitWithoutComments = emitNodeWithoutSourceMapWithoutComments; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; @@ -19201,55 +20078,108 @@ var ts; currentSourceFile = sourceFile; emit(sourceFile); } - function enterNameScope() { - var names = currentScopeNames; - currentScopeNames = undefined; - if (names) { - lastFrame = { names: names, previous: lastFrame }; - return true; - } - return false; + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); } - function exitNameScope(popFrame) { - if (popFrame) { - currentScopeNames = lastFrame.names; - lastFrame = lastFrame.previous; - } - else { - currentScopeNames = undefined; - } - } - function generateUniqueNameForLocation(location, baseName) { - var _name; - if (!isExistingName(location, baseName)) { - _name = baseName; - } - else { - _name = ts.generateUniqueName(baseName, function (n) { return isExistingName(location, n); }); - } - return recordNameInCurrentScope(_name); - } - function recordNameInCurrentScope(name) { - if (!currentScopeNames) { - currentScopeNames = {}; - } - return currentScopeNames[name] = name; - } - function isExistingName(location, name) { - if (!resolver.isUnknownIdentifier(location, name)) { - return true; - } - if (currentScopeNames && ts.hasProperty(currentScopeNames, name)) { - return true; - } - var frame = lastFrame; - while (frame) { - if (ts.hasProperty(frame.names, name)) { - return true; + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { + tempFlags |= flags; + return name; } - frame = frame.previous; } - return false; + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_12 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_12)) { + return name_12; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function assignGeneratedName(node, name) { + nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); + } + function generateNameForFunctionOrClassDeclaration(node) { + if (!node.name) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForModuleOrEnum(node) { + if (node.name.kind === 65) { + var name_13 = node.name.text; + assignGeneratedName(node, isUniqueLocalName(name_13, node) ? name_13 : makeUniqueName(name_13)); + } + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 8 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + assignGeneratedName(node, makeUniqueName(baseName)); + } + function generateNameForImportDeclaration(node) { + if (node.importClause) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportDeclaration(node) { + if (node.moduleSpecifier) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportAssignment(node) { + if (node.expression && node.expression.kind !== 65) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForNode(node) { + switch (node.kind) { + case 197: + case 198: + generateNameForFunctionOrClassDeclaration(node); + break; + case 202: + generateNameForModuleOrEnum(node); + generateNameForNode(node.body); + break; + case 201: + generateNameForModuleOrEnum(node); + break; + case 206: + generateNameForImportDeclaration(node); + break; + case 212: + generateNameForExportDeclaration(node); + break; + case 211: + generateNameForExportAssignment(node); + break; + } + } + function getGeneratedNameForNode(node) { + var nodeId = ts.getNodeId(node); + if (!nodeToGeneratedName[nodeId]) { + generateNameForNode(node); + } + return nodeToGeneratedName[nodeId]; } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -19375,8 +20305,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var _name = node.name; - if (!_name || _name.kind !== 126) { + var name_14 = node.name; + if (!name_14 || name_14.kind !== 127) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -19393,19 +20323,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 195 || - node.kind === 160 || - node.kind === 132 || - node.kind === 131 || + else if (node.kind === 197 || + node.kind === 162 || node.kind === 134 || - node.kind === 135 || - node.kind === 200 || - node.kind === 196 || - node.kind === 199) { + node.kind === 133 || + node.kind === 136 || + node.kind === 137 || + node.kind === 202 || + node.kind === 198 || + node.kind === 201) { if (node.name) { - var _name = node.name; - scopeName = _name.kind === 126 - ? ts.getTextOfNode(_name) + var name_15 = node.name; + scopeName = name_15.kind === 127 + ? ts.getTextOfNode(name_15) : node.name.text; } recordScopeNameStart(scopeName); @@ -19420,7 +20350,7 @@ var ts; ; function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { recordSourceMapSpan(comment.pos); - writeCommentRange(currentSourceFile, writer, comment, newLine); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { @@ -19448,7 +20378,7 @@ var ts; } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { encodeLastRecordedSourceMapSpan(); - writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); sourceMapDataList.push(sourceMapData); writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); } @@ -19471,7 +20401,7 @@ var ts; if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); if (root) { - sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, host, sourceMapDir)); + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -19484,32 +20414,24 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node) { + function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); + return emitNodeWithoutSourceMap(node, false); } - if (node.kind != 221) { + if (node.kind != 224) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, false); } } } - function emitNodeWithSourceMapWithoutComments(node) { - if (node) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMapWithoutComments(node); - recordEmitNodeEndSpan(node); - } - } writeEmittedFiles = writeJavaScriptAndSourceMapFile; emit = emitNodeWithSourceMap; - emitWithoutComments = emitNodeWithSourceMapWithoutComments; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -19518,24 +20440,11 @@ var ts; writeComment = writeCommentRangeWithMap; } function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } - function createTempVariable(location, preferredName) { - for (var name = preferredName; !name || isExistingName(location, name); tempCount++) { - var char = 97 + tempCount; - if (char === 105 || char === 110) { - continue; - } - if (tempCount < 26) { - name = "_" + String.fromCharCode(char); - } - else { - name = "_" + (tempCount - 26); - } - } - recordNameInCurrentScope(name); - var result = ts.createSynthesizedNode(64); - result.text = name; + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(65); + result.text = makeTempVariableName(flags); return result; } function recordTempDeclaration(name) { @@ -19544,8 +20453,8 @@ var ts; } tempVariables.push(name); } - function createAndRecordTempVariable(location, preferredName) { - var temp = createTempVariable(location, preferredName); + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); recordTempDeclaration(temp); return temp; } @@ -19737,7 +20646,7 @@ var ts; write("]"); } function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(node); + var tempVariable = createAndRecordTempVariable(0); write("("); emit(tempVariable); write(" = "); @@ -19750,10 +20659,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 169) { + if (node.template.kind === 171) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 167 + var needsParens = templateSpan.expression.kind === 169 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -19777,7 +20686,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 159 + var needsParens = templateSpan.expression.kind !== 161 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -19792,16 +20701,29 @@ var ts; write(")"); } function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar ts.Debug.assert(node.templateSpans.length !== 0); return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 155: - case 156: - return parent.expression === template; case 157: + case 158: + return parent.expression === template; case 159: + case 161: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -19809,7 +20731,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 167: + case 169: switch (expression.operatorToken.kind) { case 35: case 36: @@ -19821,7 +20743,7 @@ var ts; default: return -1; } - case 168: + case 170: return -1; default: return 1; @@ -19833,11 +20755,27 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 150); + ts.Debug.assert(node.kind !== 152); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 126) { + else if (node.kind === 127) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[node.id]; + if (generatedName) { + write(generatedName); + return; + } + var generatedVariable = createTempVariable(0); + generatedName = generatedVariable.text; + recordTempDeclaration(generatedVariable); + computedPropertyNamesToGeneratedNames[node.id] = generatedName; + write(generatedName); + write(" = "); + } emit(node.expression); } else { @@ -19852,38 +20790,43 @@ var ts; } } function isNotExpressionIdentifier(node) { - var _parent = node.parent; - switch (_parent.kind) { - case 128: - case 193: - case 150: - case 130: + var parent = node.parent; + switch (parent.kind) { case 129: - case 218: - case 219: - case 220: + case 195: + case 152: case 132: case 131: - case 195: + case 221: + case 222: + case 223: case 134: - case 135: - case 160: - case 196: + case 133: case 197: + case 136: + case 137: + case 162: + case 198: case 199: - case 200: - case 203: - return _parent.name === node; - case 185: - case 184: - case 209: + case 201: + case 202: + case 205: + case 207: + case 208: + return parent.name === node; + case 210: + case 214: + return parent.name === node || parent.propertyName === node; + case 187: + case 186: + case 211: return false; - case 189: + case 191: return node.parent.label === node; } } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node); + var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); if (substitution) { write(substitution); } @@ -19891,15 +20834,21 @@ var ts; writeTextOfNode(currentSourceFile, node); } } - function getBlockScopedVariableId(node) { - return !ts.nodeIsSynthesized(node) && resolver.getBlockScopedVariableId(node); + function getGeneratedNameForIdentifier(node) { + if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { + return undefined; + } + var variableId = resolver.getBlockScopedVariableId(node); + if (variableId === undefined) { + return undefined; + } + return blockScopedVariableToGeneratedName[variableId]; } - function emitIdentifier(node) { - var variableId = getBlockScopedVariableId(node); - if (variableId !== undefined && generatedBlockScopeNames) { - var text = generatedBlockScopeNames[variableId]; - if (text) { - write(text); + function emitIdentifier(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers) { + var generatedName = getGeneratedNameForIdentifier(node); + if (generatedName) { + write(generatedName); return; } } @@ -19922,15 +20871,17 @@ var ts; } } function emitSuper(node) { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 16) { - write("_super.prototype"); - } - else if (flags & 32) { - write("_super"); + if (languageVersion >= 2) { + write("super"); } else { - write("super"); + var flags = resolver.getNodeCheckFlags(node); + if (flags & 16) { + write("_super.prototype"); + } + else { + write("_super"); + } } } function emitObjectBindingPattern(node) { @@ -19947,7 +20898,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName); + emit(node.propertyName, false); write(": "); } if (node.dotDotDotToken) { @@ -19967,12 +20918,12 @@ var ts; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 64: - case 151: + case 65: case 153: - case 154: case 155: - case 159: + case 156: + case 157: + case 161: return false; } return true; @@ -19980,8 +20931,8 @@ var ts; function emitListWithSpread(elements, multiLine, trailingComma) { var pos = 0; var group = 0; - var _length = elements.length; - while (pos < _length) { + var length = elements.length; + while (pos < length) { if (group === 1) { write(".concat("); } @@ -19989,21 +20940,21 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 171) { + if (e.kind === 173) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { var i = pos; - while (i < _length && elements[i].kind !== 171) { + while (i < length && elements[i].kind !== 173) { i++; } write("["); if (multiLine) { increaseIndent(); } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === _length); + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); if (multiLine) { decreaseIndent(); } @@ -20017,7 +20968,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 171; + return node.kind === 173; } function emitArrayLiteral(node) { var elements = node.elements; @@ -20038,11 +20989,11 @@ var ts; return emit(parenthesizedObjectLiteral); } function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral, firstComputedPropertyIndex) { - var tempVar = createAndRecordTempVariable(originalObjectLiteral); - var initialObjectLiteral = ts.createSynthesizedNode(152); + var tempVar = createAndRecordTempVariable(0); + var initialObjectLiteral = ts.createSynthesizedNode(154); initialObjectLiteral.properties = originalObjectLiteral.properties.slice(0, firstComputedPropertyIndex); initialObjectLiteral.flags |= 512; - var propertyPatches = createBinaryExpression(tempVar, 52, initialObjectLiteral); + var propertyPatches = createBinaryExpression(tempVar, 53, initialObjectLiteral); ts.forEach(originalObjectLiteral.properties, function (property) { var patchedProperty = tryCreatePatchingPropertyAssignment(originalObjectLiteral, tempVar, property); if (patchedProperty) { @@ -20060,33 +21011,33 @@ var ts; function tryCreatePatchingPropertyAssignment(objectLiteral, tempVar, property) { var leftHandSide = createMemberAccessForPropertyName(tempVar, property.name); var maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property); - return maybeRightHandSide && createBinaryExpression(leftHandSide, 52, maybeRightHandSide, true); + return maybeRightHandSide && createBinaryExpression(leftHandSide, 53, maybeRightHandSide, true); } function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property) { switch (property.kind) { - case 218: + case 221: return property.initializer; - case 219: - return createIdentifier(resolver.getExpressionNameSubstitution(property.name)); - case 132: - return createFunctionExpression(property.parameters, property.body); + case 222: + return createIdentifier(resolver.getExpressionNameSubstitution(property.name, getGeneratedNameForNode)); case 134: - case 135: - var _a = getAllAccessorDeclarations(objectLiteral.properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + return createFunctionExpression(property.parameters, property.body); + case 136: + case 137: + var _a = ts.getAllAccessorDeclarations(objectLiteral.properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (firstAccessor !== property) { return undefined; } - var propertyDescriptor = ts.createSynthesizedNode(152); + var propertyDescriptor = ts.createSynthesizedNode(154); var descriptorProperties = []; if (getAccessor) { - var _getProperty = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body)); - descriptorProperties.push(_getProperty); + var getProperty_1 = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body)); + descriptorProperties.push(getProperty_1); } if (setAccessor) { var setProperty = createPropertyAssignment(createIdentifier("set"), createFunctionExpression(setAccessor.parameters, setAccessor.body)); descriptorProperties.push(setProperty); } - var trueExpr = ts.createSynthesizedNode(94); + var trueExpr = ts.createSynthesizedNode(95); var enumerableTrue = createPropertyAssignment(createIdentifier("enumerable"), trueExpr); descriptorProperties.push(enumerableTrue); var configurableTrue = createPropertyAssignment(createIdentifier("configurable"), trueExpr); @@ -20099,14 +21050,14 @@ var ts; } } function createParenthesizedExpression(expression) { - var result = ts.createSynthesizedNode(159); + var result = ts.createSynthesizedNode(161); result.expression = expression; return result; } function createNodeArray() { var elements = []; - for (var _i = 0; _i < arguments.length; _i++) { - elements[_i - 0] = arguments[_i]; + for (var _a = 0; _a < arguments.length; _a++) { + elements[_a - 0] = arguments[_a]; } var result = elements; result.pos = -1; @@ -20114,25 +21065,25 @@ var ts; return result; } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(167, startsOnNewLine); + var result = ts.createSynthesizedNode(169, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createExpressionStatement(expression) { - var result = ts.createSynthesizedNode(177); + var result = ts.createSynthesizedNode(179); result.expression = expression; return result; } function createMemberAccessForPropertyName(expression, memberName) { - if (memberName.kind === 64) { + if (memberName.kind === 65) { return createPropertyAccessExpression(expression, memberName); } else if (memberName.kind === 8 || memberName.kind === 7) { return createElementAccessExpression(expression, memberName); } - else if (memberName.kind === 126) { + else if (memberName.kind === 127) { return createElementAccessExpression(expression, memberName.expression); } else { @@ -20140,37 +21091,37 @@ var ts; } } function createPropertyAssignment(name, initializer) { - var result = ts.createSynthesizedNode(218); + var result = ts.createSynthesizedNode(221); result.name = name; result.initializer = initializer; return result; } function createFunctionExpression(parameters, body) { - var result = ts.createSynthesizedNode(160); + var result = ts.createSynthesizedNode(162); result.parameters = parameters; result.body = body; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(153); + var result = ts.createSynthesizedNode(155); result.expression = expression; result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(154); + var result = ts.createSynthesizedNode(156); result.expression = expression; result.argumentExpression = argumentExpression; return result; } function createIdentifier(name, startsOnNewLine) { - var result = ts.createSynthesizedNode(64, startsOnNewLine); + var result = ts.createSynthesizedNode(65, startsOnNewLine); result.text = name; return result; } function createCallExpression(invokedExpression, arguments) { - var result = ts.createSynthesizedNode(155); + var result = ts.createSynthesizedNode(157); result.expression = invokedExpression; result.arguments = arguments; return result; @@ -20181,7 +21132,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 126) { + if (properties[i].name.kind === 127) { numInitialNonComputedProperties = i; break; } @@ -20200,24 +21151,34 @@ var ts; } function emitComputedPropertyName(node) { write("["); - emit(node.expression); + emitExpressionForPropertyName(node); write("]"); } function emitMethod(node) { - emit(node.name); + emit(node.name, false); if (languageVersion < 2) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name); + emit(node.name, false); write(": "); emit(node.initializer); } function emitShorthandPropertyAssignment(node) { - emit(node.name); - if (languageVersion < 2 || resolver.getExpressionNameSubstitution(node.name)) { + emit(node.name, false); + if (languageVersion < 2) { + write(": "); + var generatedName = getGeneratedNameForIdentifier(node.name); + if (generatedName) { + write(generatedName); + } + else { + emitExpressionIdentifier(node.name); + } + } + else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { write(": "); emitExpressionIdentifier(node.name); } @@ -20227,7 +21188,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 153 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 155 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -20257,7 +21218,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); + emit(node.name, false); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -20275,20 +21236,20 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 171; }); + return ts.forEach(elements, function (e) { return e.kind === 173; }); } function skipParentheses(node) { - while (node.kind === 159 || node.kind === 158) { + while (node.kind === 161 || node.kind === 160) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 64 || node.kind === 92 || node.kind === 90) { + if (node.kind === 65 || node.kind === 93 || node.kind === 91) { emit(node); return node; } - var temp = createAndRecordTempVariable(node); + var temp = createAndRecordTempVariable(0); write("("); emit(temp); write(" = "); @@ -20299,18 +21260,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 153) { + if (expr.kind === 155) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 154) { + else if (expr.kind === 156) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 90) { + else if (expr.kind === 91) { target = expr; write("_super"); } @@ -20319,7 +21280,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 90) { + if (target.kind === 91) { emitThis(target); } else { @@ -20339,15 +21300,15 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 90) { - write("_super"); + if (node.expression.kind === 91) { + emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 153 && node.expression.expression.kind === 90; + superCall = node.expression.kind === 155 && node.expression.expression.kind === 91; } - if (superCall) { + if (superCall && languageVersion < 2) { write(".call("); emitThis(node.expression); if (node.arguments.length) { @@ -20372,7 +21333,7 @@ var ts; } } function emitTaggedTemplateExpression(node) { - if (compilerOptions.target >= 2) { + if (languageVersion >= 2) { emit(node.tag); write(" "); emit(node.template); @@ -20382,20 +21343,20 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 161) { - if (node.expression.kind === 158) { + if (!node.parent || node.parent.kind !== 163) { + if (node.expression.kind === 160) { var operand = node.expression.expression; - while (operand.kind == 158) { + while (operand.kind == 160) { operand = operand.expression; } - if (operand.kind !== 165 && - operand.kind !== 164 && - operand.kind !== 163 && - operand.kind !== 162 && + if (operand.kind !== 167 && operand.kind !== 166 && - operand.kind !== 156 && - !(operand.kind === 155 && node.parent.kind === 156) && - !(operand.kind === 160 && node.parent.kind === 155)) { + operand.kind !== 165 && + operand.kind !== 164 && + operand.kind !== 168 && + operand.kind !== 158 && + !(operand.kind === 157 && node.parent.kind === 158) && + !(operand.kind === 162 && node.parent.kind === 157)) { emit(operand); return; } @@ -20406,23 +21367,23 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(73)); + write(ts.tokenToString(74)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(96)); + write(ts.tokenToString(97)); write(" "); emit(node.expression); } function emitPrefixUnaryExpression(node) { write(ts.tokenToString(node.operator)); - if (node.operand.kind === 165) { + if (node.operand.kind === 167) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -20438,9 +21399,9 @@ var ts; write(ts.tokenToString(node.operator)); } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 52 && - (node.left.kind === 152 || node.left.kind === 151)) { - emitDestructuring(node, node.parent.kind === 177); + if (languageVersion < 2 && node.operatorToken.kind === 53 && + (node.left.kind === 154 || node.left.kind === 153)) { + emitDestructuring(node, node.parent.kind === 179); } else { emit(node.left); @@ -20476,7 +21437,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 174) { + if (node && node.kind === 176) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -20491,12 +21452,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 201) { - ts.Debug.assert(node.parent.kind === 200); + if (node.kind === 203) { + ts.Debug.assert(node.parent.kind === 202); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 201) { + if (node.kind === 203) { emitTempDeclarations(true); } decreaseIndent(); @@ -20505,7 +21466,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 174) { + if (node.kind === 176) { write(" "); emit(node); } @@ -20517,11 +21478,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 161); + emitParenthesizedIf(node.expression, node.expression.kind === 163); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); endPos = emitToken(16, endPos); emit(node.expression); @@ -20529,8 +21490,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(75, node.thenStatement.end); - if (node.elseStatement.kind === 178) { + emitToken(76, node.thenStatement.end); + if (node.elseStatement.kind === 180) { write(" "); emit(node.elseStatement); } @@ -20542,7 +21503,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 174) { + if (node.statement.kind === 176) { write(" "); } else { @@ -20559,13 +21520,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitStartOfVariableDeclarationList(decl, startPos) { - var tokenKind = 97; + var tokenKind = 98; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 104; + tokenKind = 105; } else if (ts.isConst(decl)) { - tokenKind = 69; + tokenKind = 70; } } if (startPos !== undefined) { @@ -20573,20 +21534,20 @@ var ts; } else { switch (tokenKind) { - case 97: + case 98: return write("var "); - case 104: + case 105: return write("let "); - case 69: + case 70: return write("const "); } } } function emitForStatement(node) { - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 194) { + if (node.initializer && node.initializer.kind === 196) { var variableDeclarationList = node.initializer; var declarations = variableDeclarationList.declarations; emitStartOfVariableDeclarationList(declarations[0], endPos); @@ -20604,13 +21565,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 183) { + if (languageVersion < 2 && node.kind === 185) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(81, node.pos); + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { var decl = variableDeclarationList.declarations[0]; @@ -20622,7 +21583,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 182) { + if (node.kind === 184) { write(" in "); } else { @@ -20633,13 +21594,33 @@ var ts; emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { - var endPos = emitToken(81, node.pos); + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (let _i = 0, _a = expr; _i < _a.length; _i++) { + // let v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 64; - var counter = createTempVariable(node, "_i"); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node); - var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, "_n") : undefined; + var rhsIsIdentifier = node.expression.kind === 65; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(536870912) : undefined; emitStart(node.expression); write("var "); emitNodeWithoutSourceMap(counter); @@ -20683,7 +21664,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 194) { + if (node.initializer.kind === 196) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -20698,14 +21679,14 @@ var ts; } } else { - emitNodeWithoutSourceMap(createTempVariable(node)); + emitNodeWithoutSourceMap(createTempVariable(0)); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 52, rhsIterationValue, false); - if (node.initializer.kind === 151 || node.initializer.kind === 152) { + var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); + if (node.initializer.kind === 153 || node.initializer.kind === 154) { emitDestructuring(assignmentExpression, true, undefined, node); } else { @@ -20714,7 +21695,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 174) { + if (node.statement.kind === 176) { emitLines(node.statement.statements); } else { @@ -20726,12 +21707,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 185 ? 65 : 70, node.pos); + emitToken(node.kind === 187 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(89, node.pos); + emitToken(90, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -20742,7 +21723,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(91, node.pos); + var endPos = emitToken(92, node.pos); write(" "); emitToken(16, endPos); emit(node.expression); @@ -20759,19 +21740,19 @@ var ts; emitToken(15, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function nodeEndPositionsAreOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, node2.end); + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); } function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 214) { + if (node.kind === 217) { write("case "); emit(node.expression); write(":"); @@ -20806,7 +21787,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(67, node.pos); + var endPos = emitToken(68, node.pos); write(" "); emitToken(16, endPos); emit(node.variableDeclaration); @@ -20815,7 +21796,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(71, node.pos); + emitToken(72, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -20826,18 +21807,24 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 200); + } while (node && node.kind !== 202); return node; } function emitContainingModuleName(node) { var container = getContainingModule(node); - write(container ? resolver.getGeneratedNameForNode(container) : "exports"); + write(container ? getGeneratedNameForNode(container) : "exports"); } function emitModuleMemberName(node) { emitStart(node.name); if (ts.getCombinedNodeFlags(node) & 1) { - emitContainingModuleName(node); - write("."); + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (languageVersion < 2) { + write("exports."); + } } emitNodeWithoutSourceMap(node.name); emitEnd(node.name); @@ -20845,13 +21832,30 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(166); result.expression = zero; return result; } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (node.name) { + emitModuleMemberName(node); + } + else { + write("exports.default"); + } + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + } function emitExportMemberAssignments(name) { - if (!exportDefault && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - ts.forEach(exportSpecifiers[name.text], function (specifier) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text], _c = _b.length; _a < _c; _a++) { + var specifier = _b[_a]; writeLine(); emitStart(specifier.name); emitContainingModuleName(specifier); @@ -20859,15 +21863,15 @@ var ts; emitNodeWithoutSourceMap(specifier.name); emitEnd(specifier.name); write(" = "); - emitNodeWithoutSourceMap(name); + emitExpressionIdentifier(name); write(";"); - }); + } } } function emitDestructuring(root, isAssignmentExpressionStatement, value, lowestNonSynthesizedAncestor) { var emitCount = 0; - var _isDeclaration = (root.kind === 193 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 128; - if (root.kind === 167) { + var isDeclaration = (root.kind === 195 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 129; + if (root.kind === 169) { emitAssignmentExpression(root); } else { @@ -20879,7 +21883,7 @@ var ts; write(", "); } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === 193 || name.parent.kind === 150)) { + if (name.parent && (name.parent.kind === 195 || name.parent.kind === 152)) { emitModuleMemberName(name.parent); } else { @@ -20889,9 +21893,9 @@ var ts; emit(value); } function ensureIdentifier(expr) { - if (expr.kind !== 64) { - var identifier = createTempVariable(lowestNonSynthesizedAncestor || root); - if (!_isDeclaration) { + if (expr.kind !== 65) { + var identifier = createTempVariable(0); + if (!isDeclaration) { recordTempDeclaration(identifier); } emitAssignment(identifier, expr); @@ -20901,14 +21905,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(167); + var equals = ts.createSynthesizedNode(169); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(168); + var cond = ts.createSynthesizedNode(170); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -20922,21 +21926,21 @@ var ts; return node; } function parenthesizeForAccess(expr) { - if (expr.kind === 64 || expr.kind === 153 || expr.kind === 154) { + if (expr.kind === 65 || expr.kind === 155 || expr.kind === 156) { return expr; } - var node = ts.createSynthesizedNode(159); + var node = ts.createSynthesizedNode(161); node.expression = expr; return node; } function createPropertyAccess(object, propName) { - if (propName.kind !== 64) { + if (propName.kind !== 65) { return createElementAccess(object, propName); } return createPropertyAccessExpression(parenthesizeForAccess(object), propName); } function createElementAccess(object, index) { - var node = ts.createSynthesizedNode(154); + var node = ts.createSynthesizedNode(156); node.expression = parenthesizeForAccess(object); node.argumentExpression = index; return node; @@ -20946,9 +21950,9 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value); } - for (var _i = 0, _n = properties.length; _i < _n; _i++) { - var p = properties[_i]; - if (p.kind === 218 || p.kind === 219) { + for (var _a = 0, _b = properties.length; _a < _b; _a++) { + var p = properties[_a]; + if (p.kind === 221 || p.kind === 222) { var propName = (p.name); emitDestructuringAssignment(p.initializer || propName, createPropertyAccess(value, propName)); } @@ -20961,8 +21965,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 172) { - if (e.kind !== 171) { + if (e.kind !== 174) { + if (e.kind !== 173) { emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i))); } else { @@ -20976,14 +21980,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 167 && target.operatorToken.kind === 52) { + if (target.kind === 169 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 152) { + if (target.kind === 154) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 151) { + else if (target.kind === 153) { emitArrayLiteralAssignment(target, value); } else { @@ -20992,19 +21996,19 @@ var ts; } function emitAssignmentExpression(root) { var target = root.left; - var _value = root.right; + var value = root.right; if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, _value); + emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 159) { + if (root.parent.kind !== 161) { write("("); } - _value = ensureIdentifier(_value); - emitDestructuringAssignment(target, _value); + value = ensureIdentifier(value); + emitDestructuringAssignment(target, value); write(", "); - emit(_value); - if (root.parent.kind !== 159) { + emit(value); + if (root.parent.kind !== 161) { write(")"); } } @@ -21024,11 +22028,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 148) { + if (pattern.kind === 150) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccess(value, propName)); } - else if (element.kind !== 172) { + else if (element.kind !== 174) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccess(value, createNumericLiteral(i))); } @@ -21065,8 +22069,8 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 182 && - node.parent.parent.kind !== 183) { + node.parent.parent.kind !== 184 && + node.parent.parent.kind !== 185) { initializer = createVoidZero(); } } @@ -21074,16 +22078,19 @@ var ts; } } function emitExportVariableAssignments(node) { - var _name = node.name; - if (_name.kind === 64) { - emitExportMemberAssignments(_name); + if (node.kind === 174) { + return; } - else if (ts.isBindingPattern(_name)) { - ts.forEach(_name.elements, emitExportVariableAssignments); + var name = node.name; + if (name.kind === 65) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 193 && node.parent.kind !== 150)) { + if (!node.parent || (node.parent.kind !== 195 && node.parent.kind !== 152)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -21091,33 +22098,49 @@ var ts; function renameNonTopLevelLetAndConst(node) { if (languageVersion >= 2 || ts.nodeIsSynthesized(node) || - node.kind !== 64 || - (node.parent.kind !== 193 && node.parent.kind !== 150)) { + node.kind !== 65 || + (node.parent.kind !== 195 && node.parent.kind !== 152)) { return; } var combinedFlags = getCombinedFlagsForIdentifier(node); if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { return; } - var list = ts.getAncestor(node, 194); - if (list.parent.kind === 175 && list.parent.parent.kind === 221) { - return; + var list = ts.getAncestor(node, 196); + if (list.parent.kind === 177) { + var isSourceFileLevelBinding = list.parent.parent.kind === 224; + var isModuleLevelBinding = list.parent.parent.kind === 203; + var isFunctionLevelBinding = list.parent.parent.kind === 176 && ts.isFunctionLike(list.parent.parent.parent); + if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { + return; + } } var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var _parent = blockScopeContainer.kind === 221 + var parent = blockScopeContainer.kind === 224 ? blockScopeContainer : blockScopeContainer.parent; - var generatedName = generateUniqueNameForLocation(_parent, node.text); - var variableId = resolver.getBlockScopedVariableId(node); - if (!generatedBlockScopeNames) { - generatedBlockScopeNames = []; + if (resolver.resolvesToSomeValue(parent, node.text)) { + var variableId = resolver.getBlockScopedVariableId(node); + if (!blockScopedVariableToGeneratedName) { + blockScopedVariableToGeneratedName = []; + } + var generatedName = makeUniqueName(node.text); + blockScopedVariableToGeneratedName[variableId] = generatedName; } - generatedBlockScopeNames[variableId] = generatedName; + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + languageVersion >= 2 && + node.parent.kind === 224; } function emitVariableStatement(node) { if (!(node.flags & 1)) { emitStartOfVariableDeclarationList(node.declarationList); } + else if (isES6ExportedDeclaration(node)) { + write("export "); + emitStartOfVariableDeclarationList(node.declarationList); + } emitCommaList(node.declarationList.declarations); write(";"); if (languageVersion < 2 && node.parent === currentSourceFile) { @@ -21127,12 +22150,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var _name = createTempVariable(node); + var name_16 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(_name); - emit(_name); + tempParameters.push(name_16); + emit(name_16); } else { emit(node.name); @@ -21179,7 +22202,7 @@ var ts; if (languageVersion < 2 && ts.hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; - var tempName = createTempVariable(node, "_i").text; + var tempName = createTempVariable(268435456).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -21214,39 +22237,53 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 134 ? "get " : "set "); - emit(node.name); + write(node.kind === 136 ? "get " : "set "); + emit(node.name, false); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 161 && languageVersion >= 2; + return node.kind === 163 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { emitNodeWithoutSourceMap(node.name); } else { - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 162) { + return !!node.name; + } + else if (node.kind === 197) { + return !!node.name || (languageVersion >= 2 && !(node.flags & 256)); } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 134 && node.kind !== 133) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256) { + write("default "); + } + } write("function "); } - if (node.kind === 195 || (node.kind === 160 && node.name)) { + if (shouldEmitFunctionName(node)) { emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 195 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 197 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 134 && node.kind !== 133) { emitTrailingComments(node); } } @@ -21277,13 +22314,12 @@ var ts; emitSignatureParameters(node); } function emitSignatureAndBody(node) { - var saveTempCount = tempCount; + var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; var saveTempParameters = tempParameters; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; tempParameters = undefined; - var popFrame = enterNameScope(); if (shouldEmitAsArrowFunction(node)) { emitSignatureParametersForArrow(node); write(" =>"); @@ -21294,23 +22330,16 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 174) { + else if (node.body.kind === 176) { emitBlockFunctionBody(node, node.body); } else { emitExpressionFunctionBody(node, node.body); } - if (node.flags & 1 && !(node.flags & 256)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); } - exitNameScope(popFrame); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; } @@ -21326,10 +22355,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 158) { + while (current.kind === 160) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 152); + emitParenthesizedIf(body, current.kind === 154); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -21344,7 +22373,7 @@ var ts; write(" "); emitStart(body); write("return "); - emitWithoutComments(body); + emit(body); emitEnd(body); write(";"); emitTempDeclarations(false); @@ -21355,7 +22384,7 @@ var ts; writeLine(); emitLeadingComments(node.body); write("return "); - emitWithoutComments(node.body); + emit(body); write(";"); emitTrailingComments(node.body); emitTempDeclarations(true); @@ -21378,8 +22407,8 @@ var ts; decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; if (preserveNewLines && !preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _i = 0, _a = body.statements, _n = _a.length; _i < _n; _i++) { - var statement = _a[_i]; + for (var _a = 0, _b = body.statements, _c = _b.length; _a < _c; _a++) { + var statement = _b[_a]; write(" "); emit(statement); } @@ -21401,11 +22430,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 177) { + if (statement && statement.kind === 179) { var expr = statement.expression; - if (expr && expr.kind === 155) { + if (expr && expr.kind === 157) { var func = expr.expression; - if (func && func.kind === 90) { + if (func && func.kind === 91) { return statement; } } @@ -21434,7 +22463,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 126) { + else if (memberName.kind === 127) { emitComputedPropertyName(memberName); } else { @@ -21444,7 +22473,7 @@ var ts; } function emitMemberAssignments(node, staticFlag) { ts.forEach(node.members, function (member) { - if (member.kind === 130 && (member.flags & 128) === staticFlag && member.initializer) { + if (member.kind === 132 && (member.flags & 128) === staticFlag && member.initializer) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -21465,20 +22494,17 @@ var ts; } }); } - function emitMemberFunctions(node) { + function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 132 || node.kind === 131) { + if (member.kind === 134 || node.kind === 133) { if (!member.body) { - return emitPinnedOrTripleSlashComments(member); + return emitOnlyPinnedOrTripleSlashComments(member); } writeLine(); emitLeadingComments(member); emitStart(member); emitStart(member.name); - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); @@ -21489,17 +22515,14 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 134 || member.kind === 135) { - var accessors = getAllAccessorDeclarations(node.members, member); + else if (member.kind === 136 || member.kind === 137) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); emitStart(member); write("Object.defineProperty("); emitStart(member.name); - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); @@ -21539,7 +22562,207 @@ var ts; } }); } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members, _c = _b.length; _a < _c; _a++) { + var member = _b[_a]; + if ((member.kind === 134 || node.kind === 133) && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + else if (member.kind === 134 || node.kind === 133 || member.kind === 136 || member.kind === 137) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 136) { + write("get "); + } + else if (member.kind === 137) { + write("set "); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + } + } + function emitConstructor(node, baseTypeNode) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 135 && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + if (member.kind === 132 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeNode) { + write("(...args)"); + } + else { + write("()"); + } + } + } + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeNode) { + var superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeNode); + } + } + emitMemberAssignments(node, 0); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLines(statements); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } function emitClassDeclaration(node) { + if (languageVersion < 2) { + emitClassDeclarationBelowES6(node); + } + else { + emitClassDeclarationForES6AndHigher(node); + } + } + function emitClassDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256) { + write("default "); + } + } + write("class"); + if ((node.name || !(node.flags & 256)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.typeName); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(15, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + if (node.name) { + writeLine(); + write("Object.defineProperty("); + emitDeclarationName(node); + write(", \"name\", { value: \""); + emitDeclarationName(node); + write("\", configurable: true });"); + writeLine(); + } + } + writeLine(); + emitMemberAssignments(node, 128); + emitDecoratorsOfClass(node); + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 256) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassDeclarationBelowES6(node) { write("var "); emitDeclarationName(node); write(" = (function ("); @@ -21548,6 +22771,14 @@ var ts; write("_super"); } write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; increaseIndent(); scopeEmitStart(node); if (baseTypeNode) { @@ -21559,15 +22790,22 @@ var ts; emitEnd(baseTypeNode); } writeLine(); - emitConstructorOfClass(); - emitMemberFunctions(node); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); emitMemberAssignments(node, 128); writeLine(); + emitDecoratorsOfClass(node); + writeLine(); emitToken(15, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); emitToken(15, node.members.end); @@ -21579,94 +22817,147 @@ var ts; } write(");"); emitEnd(node); - if (node.flags & 1 && !(node.flags & 256)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } + emitExportMemberAssignment(node); if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - function emitConstructorOfClass() { - var saveTempCount = tempCount; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempCount = 0; - tempVariables = undefined; - tempParameters = undefined; - var popFrame = enterNameScope(); - ts.forEach(node.members, function (member) { - if (member.kind === 133 && !member.body) { - emitPinnedOrTripleSlashComments(member); - } - }); - var ctor = getFirstConstructorWithBody(node); - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeNode) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("_super.apply(this, arguments);"); - emitEnd(baseTypeNode); - } - } - emitMemberAssignments(node, 0); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) - statements = statements.slice(1); - emitLines(statements); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - exitNameScope(popFrame); - tempCount = saveTempCount; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); } } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var constructor = ts.getFirstConstructorWithBody(node); + if (constructor) { + emitDecoratorsOfParameters(node, constructor); + } + if (!ts.nodeIsDecorated(node)) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = "); + emitDecorateStart(node.decorators); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + ts.forEach(node.members, function (member) { + if ((member.flags & 128) !== staticFlag) { + return; + } + var decorators; + switch (member.kind) { + case 134: + emitDecoratorsOfParameters(node, member); + decorators = member.decorators; + break; + case 136: + case 137: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + return; + } + if (accessors.setAccessor) { + emitDecoratorsOfParameters(node, accessors.setAccessor); + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + break; + case 132: + decorators = member.decorators; + break; + default: + return; + } + if (!decorators) { + return; + } + writeLine(); + emitStart(member); + if (member.kind !== 132) { + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", "); + } + emitDecorateStart(decorators); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (member.kind !== 132) { + write(", Object.getOwnPropertyDescriptor("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write("))"); + } + write(");"); + emitEnd(member); + writeLine(); + }); + } + function emitDecoratorsOfParameters(node, member) { + ts.forEach(member.parameters, function (parameter, parameterIndex) { + if (!ts.nodeIsDecorated(parameter)) { + return; + } + writeLine(); + emitStart(parameter); + emitDecorateStart(parameter.decorators); + emitStart(parameter.name); + if (member.kind === 135) { + emitDeclarationName(node); + write(", void 0"); + } + else { + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + } + write(", "); + write(String(parameterIndex)); + emitEnd(parameter.name); + write(");"); + emitEnd(parameter); + writeLine(); + }); + } + function emitDecorateStart(decorators) { + write("__decorate(["); + var decoratorCount = decorators.length; + for (var i = 0; i < decoratorCount; i++) { + if (i > 0) { + write(", "); + } + var decorator = decorators[i]; + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + } + write("], "); + } function emitInterfaceDeclaration(node) { - emitPinnedOrTripleSlashComments(node); + emitOnlyPinnedOrTripleSlashComments(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -21676,8 +22967,11 @@ var ts; if (!shouldEmitEnumDeclaration(node)) { return; } - if (!(node.flags & 1)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); emitEnd(node); @@ -21687,7 +22981,7 @@ var ts; emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") {"); increaseIndent(); @@ -21703,7 +22997,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (node.flags & 1) { + if (!isES6ExportedDeclaration(node) && node.flags & 1) { writeLine(); emitStart(node); write("var "); @@ -21720,9 +23014,9 @@ var ts; function emitEnumMember(node) { var enumParent = node.parent; emitStart(node); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); emitExpressionForPropertyName(node.name); write("] = "); @@ -21733,14 +23027,12 @@ var ts; write(";"); } function writeEnumMemberDeclarationValue(member) { - if (!member.initializer || ts.isConst(member.parent)) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; } - if (member.initializer) { + else if (member.initializer) { emit(member.initializer); } else { @@ -21748,7 +23040,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 200) { + if (moduleDeclaration.body.kind === 202) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -21759,9 +23051,12 @@ var ts; function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); write(";"); @@ -21770,18 +23065,16 @@ var ts; emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 201) { - var saveTempCount = tempCount; + if (node.body.kind === 203) { + var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; - tempCount = 0; + tempFlags = 0; tempVariables = undefined; - var popFrame = enterNameScope(); emit(node.body); - exitNameScope(popFrame); - tempCount = saveTempCount; + tempFlags = saveTempFlags; tempVariables = saveTempVariables; } else { @@ -21798,7 +23091,7 @@ var ts; scopeEmitEnd(); } write(")("); - if (node.flags & 1) { + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -21807,7 +23100,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (languageVersion < 2 && node.name.kind === 64 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 65 && node.parent === currentSourceFile) { emitExportMemberAssignments(node.name); } } @@ -21818,199 +23111,303 @@ var ts; emitLiteral(moduleName); emitEnd(moduleName); emitToken(17, moduleName.end); - write(";"); } else { - write("require();"); + write("require()"); } } + function getNamespaceDeclarationNode(node) { + if (node.kind === 205) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 208) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 206 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } function emitImportDeclaration(node) { - var info = getExternalImportInfo(node); - if (info) { - var declarationNode = info.declarationNode; - var namedImports = info.namedImports; + if (languageVersion < 2) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 208) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 205 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); emitStart(node); - var moduleName = ts.getExternalModuleName(node); - if (declarationNode) { - if (!(declarationNode.flags & 1)) + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) write("var "); - emitModuleMemberName(declarationNode); + emitModuleMemberName(namespaceDeclaration); write(" = "); - emitRequire(moduleName); - } - else if (namedImports) { - write("var "); - write(resolver.getGeneratedNameForNode(node)); - write(" = "); - emitRequire(moduleName); } else { - emitRequire(moduleName); + var isNakedImport = 206 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } else { - if (declarationNode) { - if (declarationNode.flags & 1) { - emitModuleMemberName(declarationNode); - write(" = "); - emit(declarationNode.name); - write(";"); - } + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); } } } function emitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitImportDeclaration(node); + emitExternalImportDeclaration(node); return; } if (resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (!(node.flags & 1)) + if (isES6ExportedDeclaration(node)) { + write("export "); write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } } function emitExportDeclaration(node) { - if (node.moduleSpecifier) { - emitStart(node); - var generatedName = resolver.getGeneratedNameForNode(node); - if (compilerOptions.module !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - } - if (node.exportClause) { - ts.forEach(node.exportClause.elements, function (specifier) { + if (languageVersion < 2) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (compilerOptions.module !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements, _c = _b.length; _a < _c; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write("__export("); + if (compilerOptions.module !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + emitStart(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emitNodeWithoutSourceMap(node.moduleSpecifier); + } + write(";"); + emitEnd(node); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(languageVersion >= 2); + var needsComma = false; + for (var _a = 0, _b = specifiers.length; _a < _b; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + emitStart(specifier); + if (specifier.propertyName) { + emitNodeWithoutSourceMap(specifier.propertyName); + write(" as "); + } + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (languageVersion >= 2) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 197 && + expression.kind !== 198) { write(";"); - emitEnd(specifier); - }); + } + emitEnd(node); } else { - var tempName = createTempVariable(node).text; writeLine(); - write("for (var " + tempName + " in " + generatedName + ") if (!"); + emitStart(node); emitContainingModuleName(node); - write(".hasOwnProperty(" + tempName + ")) "); - emitContainingModuleName(node); - write("[" + tempName + "] = " + generatedName + "[" + tempName + "];"); - } - emitEnd(node); - } - } - function createExternalImportInfo(node) { - if (node.kind === 203) { - if (node.moduleReference.kind === 213) { - return { - rootNode: node, - declarationNode: node - }; - } - } - else if (node.kind === 204) { - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - return { - rootNode: node, - declarationNode: importClause - }; - } - if (importClause.namedBindings.kind === 206) { - return { - rootNode: node, - declarationNode: importClause.namedBindings - }; - } - return { - rootNode: node, - namedImports: importClause.namedBindings, - localName: resolver.getGeneratedNameForNode(node) - }; - } - return { - rootNode: node - }; - } - else if (node.kind === 210) { - if (node.moduleSpecifier) { - return { - rootNode: node - }; + write(".default = "); + emit(node.expression); + write(";"); + emitEnd(node); } } } - function createExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile) { externalImports = []; exportSpecifiers = {}; - exportDefault = undefined; - ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 210 && !node.moduleSpecifier) { - ts.forEach(node.exportClause.elements, function (specifier) { - if (specifier.name.text === "default") { - exportDefault = exportDefault || specifier; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements, _c = _b.length; _a < _c; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 206: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); } - var _name = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[_name] || (exportSpecifiers[_name] = [])).push(specifier); - }); - } - else if (node.kind === 209) { - exportDefault = exportDefault || node; - } - else if (node.kind === 195 || node.kind === 196) { - if (node.flags & 1 && node.flags & 256) { - exportDefault = exportDefault || node; - } - } - else { - var info = createExternalImportInfo(node); - if (info) { - if ((!info.declarationNode && !info.namedImports) || resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(info); + break; + case 205: + if (node.moduleReference.kind === 216 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); } - } - } - }); - } - function getExternalImportInfo(node) { - if (externalImports) { - for (var _i = 0, _n = externalImports.length; _i < _n; _i++) { - var info = externalImports[_i]; - if (info.rootNode === node) { - return info; - } + break; + case 212: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _d = 0, _e = node.exportClause.elements, _f = _e.length; _d < _f; _d++) { + var specifier = _e[_d]; + var name_17 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_17] || (exportSpecifiers[name_17] = [])).push(specifier); + } + } + break; + case 211: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; } } } - function getFirstExportAssignment(sourceFile) { - return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 209) { - return node; - } - }); - } function sortAMDModules(amdModules) { return amdModules.sort(function (moduleA, moduleB) { if (moduleA.name === moduleB.name) { @@ -22024,7 +23421,20 @@ var ts; } }); } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); writeLine(); write("define("); sortAMDModules(node.amdDependencies); @@ -22032,69 +23442,78 @@ var ts; write("\"" + node.amdModuleName + "\", "); } write("[\"require\", \"exports\""); - ts.forEach(externalImports, function (info) { + for (var _a = 0, _b = externalImports.length; _a < _b; _a++) { + var importNode = externalImports[_a]; write(", "); - var moduleName = ts.getExternalModuleName(info.rootNode); + var moduleName = ts.getExternalModuleName(importNode); if (moduleName.kind === 8) { emitLiteral(moduleName); } else { write("\"\""); } - }); - ts.forEach(node.amdDependencies, function (amdDependency) { + } + for (var _c = 0, _d = node.amdDependencies, _e = _d.length; _c < _e; _c++) { + var amdDependency = _d[_c]; var text = "\"" + amdDependency.path + "\""; write(", "); write(text); - }); + } write("], function (require, exports"); - ts.forEach(externalImports, function (info) { + for (var _f = 0, _g = externalImports.length; _f < _g; _f++) { + var importNode = externalImports[_f]; write(", "); - if (info.declarationNode) { - emit(info.declarationNode.name); + var namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + emit(namespaceDeclaration.name); } else { - write(resolver.getGeneratedNameForNode(info.rootNode)); + write(getGeneratedNameForNode(importNode)); } - }); - ts.forEach(node.amdDependencies, function (amdDependency) { + } + for (var _h = 0, _j = node.amdDependencies, _k = _j.length; _h < _k; _h++) { + var amdDependency = _j[_h]; if (amdDependency.name) { write(", "); write(amdDependency.name); } - }); + } write(") {"); increaseIndent(); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - emitExportDefault(node, true); + emitExportEquals(true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + collectExternalModuleInfo(node); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - emitExportDefault(node, false); + emitExportEquals(false); } - function emitExportDefault(sourceFile, emitAsReturn) { - if (exportDefault && resolver.hasExportDefaultValue(sourceFile)) { + function emitES6Module(node, startIndex) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { writeLine(); - emitStart(exportDefault); + emitStart(exportEquals); write(emitAsReturn ? "return " : "module.exports = "); - if (exportDefault.kind === 209) { - emit(exportDefault.expression); - } - else if (exportDefault.kind === 212) { - emit(exportDefault.propertyName); - } - else { - emitDeclarationName(exportDefault); - } + emit(exportEquals.expression); write(";"); - emitEnd(exportDefault); + emitEnd(exportEquals); } } function emitDirectivePrologues(statements, startWithNewLine) { @@ -22111,11 +23530,21 @@ var ts; } return statements.length; } + function writeHelper(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } function emitSourceFileNode(node) { writeLine(); emitDetachedComments(node); var startIndex = emitDirectivePrologues(node.statements, false); - if (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLine(); write("var __extends = this.__extends || function (d, b) {"); increaseIndent(); @@ -22132,9 +23561,15 @@ var ts; write("};"); extendsEmitted = true; } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { + writeHelper("\nvar __decorate = this.__decorate || function (decorators, target, key, value) {\n var kind = typeof (arguments.length == 2 ? value = target : value);\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n switch (kind) {\n case \"function\": value = decorator(value) || value; break;\n case \"number\": decorator(target, key, value); break;\n case \"undefined\": decorator(target, key); break;\n case \"object\": value = decorator(target, key, value) || value; break;\n }\n }\n return value;\n};"); + decorateEmitted = true; + } if (ts.isExternalModule(node)) { - createExternalModuleInfo(node); - if (compilerOptions.module === 2) { + if (languageVersion >= 2) { + emitES6Module(node, startIndex); + } + else if (compilerOptions.module === 2) { emitAMDModule(node, startIndex); } else { @@ -22144,75 +23579,75 @@ var ts; else { externalImports = undefined; exportSpecifiers = undefined; - exportDefault = undefined; + exportEquals = undefined; + hasExportStars = false; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMapWithComments(node) { + function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { if (!node) { return; } if (node.flags & 2) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } - var _emitComments = shouldEmitLeadingAndTrailingComments(node); - if (_emitComments) { + var emitComments = shouldEmitLeadingAndTrailingComments(node); + if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node); - if (_emitComments) { + emitJavaScriptWorker(node, allowGeneratedIdentifiers); + if (emitComments) { emitTrailingComments(node); } } - function emitNodeWithoutSourceMapWithoutComments(node) { - if (!node) { - return; - } - if (node.flags & 2) { - return emitPinnedOrTripleSlashComments(node); - } - emitJavaScriptWorker(node); - } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 197: - case 195: - case 204: - case 203: - case 198: - case 209: - return false; - case 200: - return shouldEmitModuleDeclaration(node); case 199: + case 197: + case 206: + case 205: + case 200: + case 211: + return false; + case 202: + return shouldEmitModuleDeclaration(node); + case 201: return shouldEmitEnumDeclaration(node); } + if (node.kind !== 176 && + node.parent && + node.parent.kind === 163 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } return true; } - function emitJavaScriptWorker(node) { + function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } switch (node.kind) { - case 64: - return emitIdentifier(node); - case 128: + case 65: + return emitIdentifier(node, allowGeneratedIdentifiers); + case 129: return emitParameter(node); - case 132: - case 131: - return emitMethod(node); case 134: - case 135: + case 133: + return emitMethod(node); + case 136: + case 137: return emitAccessor(node); - case 92: + case 93: return emitThis(node); - case 90: + case 91: return emitSuper(node); - case 88: + case 89: return write("null"); - case 94: + case 95: return write("true"); - case 79: + case 80: return write("false"); case 7: case 8: @@ -22222,125 +23657,127 @@ var ts; case 12: case 13: return emitLiteral(node); - case 169: - return emitTemplateExpression(node); - case 173: - return emitTemplateSpan(node); - case 125: - return emitQualifiedName(node); - case 148: - return emitObjectBindingPattern(node); - case 149: - return emitArrayBindingPattern(node); - case 150: - return emitBindingElement(node); - case 151: - return emitArrayLiteral(node); - case 152: - return emitObjectLiteral(node); - case 218: - return emitPropertyAssignment(node); - case 219: - return emitShorthandPropertyAssignment(node); - case 126: - return emitComputedPropertyName(node); - case 153: - return emitPropertyAccess(node); - case 154: - return emitIndexedAccess(node); - case 155: - return emitCallExpression(node); - case 156: - return emitNewExpression(node); - case 157: - return emitTaggedTemplateExpression(node); - case 158: - return emit(node.expression); - case 159: - return emitParenExpression(node); - case 195: - case 160: - case 161: - return emitFunctionDeclaration(node); - case 162: - return emitDeleteExpression(node); - case 163: - return emitTypeOfExpression(node); - case 164: - return emitVoidExpression(node); - case 165: - return emitPrefixUnaryExpression(node); - case 166: - return emitPostfixUnaryExpression(node); - case 167: - return emitBinaryExpression(node); - case 168: - return emitConditionalExpression(node); case 171: - return emitSpreadElementExpression(node); - case 172: - return; - case 174: - case 201: - return emitBlock(node); + return emitTemplateExpression(node); case 175: - return emitVariableStatement(node); - case 176: - return write(";"); - case 177: - return emitExpressionStatement(node); - case 178: - return emitIfStatement(node); - case 179: - return emitDoStatement(node); - case 180: - return emitWhileStatement(node); - case 181: - return emitForStatement(node); - case 183: - case 182: - return emitForInOrForOfStatement(node); - case 184: - case 185: - return emitBreakOrContinueStatement(node); - case 186: - return emitReturnStatement(node); - case 187: - return emitWithStatement(node); - case 188: - return emitSwitchStatement(node); - case 214: - case 215: - return emitCaseOrDefaultClause(node); - case 189: - return emitLabelledStatement(node); - case 190: - return emitThrowStatement(node); - case 191: - return emitTryStatement(node); - case 217: - return emitCatchClause(node); - case 192: - return emitDebuggerStatement(node); - case 193: - return emitVariableDeclaration(node); - case 196: - return emitClassDeclaration(node); - case 197: - return emitInterfaceDeclaration(node); - case 199: - return emitEnumDeclaration(node); - case 220: - return emitEnumMember(node); - case 200: - return emitModuleDeclaration(node); - case 204: - return emitImportDeclaration(node); - case 203: - return emitImportEqualsDeclaration(node); - case 210: - return emitExportDeclaration(node); + return emitTemplateSpan(node); + case 126: + return emitQualifiedName(node); + case 150: + return emitObjectBindingPattern(node); + case 151: + return emitArrayBindingPattern(node); + case 152: + return emitBindingElement(node); + case 153: + return emitArrayLiteral(node); + case 154: + return emitObjectLiteral(node); case 221: + return emitPropertyAssignment(node); + case 222: + return emitShorthandPropertyAssignment(node); + case 127: + return emitComputedPropertyName(node); + case 155: + return emitPropertyAccess(node); + case 156: + return emitIndexedAccess(node); + case 157: + return emitCallExpression(node); + case 158: + return emitNewExpression(node); + case 159: + return emitTaggedTemplateExpression(node); + case 160: + return emit(node.expression); + case 161: + return emitParenExpression(node); + case 197: + case 162: + case 163: + return emitFunctionDeclaration(node); + case 164: + return emitDeleteExpression(node); + case 165: + return emitTypeOfExpression(node); + case 166: + return emitVoidExpression(node); + case 167: + return emitPrefixUnaryExpression(node); + case 168: + return emitPostfixUnaryExpression(node); + case 169: + return emitBinaryExpression(node); + case 170: + return emitConditionalExpression(node); + case 173: + return emitSpreadElementExpression(node); + case 174: + return; + case 176: + case 203: + return emitBlock(node); + case 177: + return emitVariableStatement(node); + case 178: + return write(";"); + case 179: + return emitExpressionStatement(node); + case 180: + return emitIfStatement(node); + case 181: + return emitDoStatement(node); + case 182: + return emitWhileStatement(node); + case 183: + return emitForStatement(node); + case 185: + case 184: + return emitForInOrForOfStatement(node); + case 186: + case 187: + return emitBreakOrContinueStatement(node); + case 188: + return emitReturnStatement(node); + case 189: + return emitWithStatement(node); + case 190: + return emitSwitchStatement(node); + case 217: + case 218: + return emitCaseOrDefaultClause(node); + case 191: + return emitLabelledStatement(node); + case 192: + return emitThrowStatement(node); + case 193: + return emitTryStatement(node); + case 220: + return emitCatchClause(node); + case 194: + return emitDebuggerStatement(node); + case 195: + return emitVariableDeclaration(node); + case 198: + return emitClassDeclaration(node); + case 199: + return emitInterfaceDeclaration(node); + case 201: + return emitEnumDeclaration(node); + case 223: + return emitEnumMember(node); + case 202: + return emitModuleDeclaration(node); + case 206: + return emitImportDeclaration(node); + case 205: + return emitImportEqualsDeclaration(node); + case 212: + return emitExportDeclaration(node); + case 211: + return emitExportAssignment(node); + case 224: return emitSourceFileNode(node); } } @@ -22357,34 +23794,50 @@ var ts; } return leadingComments; } + function filterComments(ranges, onlyPinnedOrTripleSlashComments) { + if (ranges && onlyPinnedOrTripleSlashComments) { + ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); + if (ranges.length === 0) { + return undefined; + } + } + return ranges; + } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 221 || node.pos !== node.parent.pos) { - var leadingComments; + if (node.parent.kind === 224 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); + return getLeadingCommentsWithoutDetachedComments(); } else { - leadingComments = ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); } - return leadingComments; } } } - function emitLeadingDeclarationComments(node) { - var leadingComments = getLeadingCommentsToEmit(node); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingDeclarationComments(node) { + function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 221 || node.end !== node.parent.end) { - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + if (node.parent.kind === 224 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitLeadingCommentsOfLocalPosition(pos) { + function emitOnlyPinnedOrTripleSlashComments(node) { + emitLeadingCommentsWorker(node, true); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + } + function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { + var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitLeadingCommentsOfPosition(pos) { var leadingComments; if (hasDetachedComments(pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -22392,18 +23845,19 @@ var ts; else { leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + leadingComments = filterComments(leadingComments, compilerOptions.removeComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } - function emitDetachedCommentsAtPosition(node) { + function emitDetachedComments(node) { var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); if (leadingComments) { var detachedComments = []; var lastComment; ts.forEach(leadingComments, function (comment) { if (lastComment) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); if (commentLine >= lastCommentLine + 2) { return detachedComments; } @@ -22412,11 +23866,11 @@ var ts; lastComment = comment; }); if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); - var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -22428,54 +23882,53 @@ var ts; } } } - function emitPinnedOrTripleSlashComments(node) { - var pinnedComments = ts.filter(getLeadingCommentsToEmit(node), isPinnedOrTripleSlashComment); - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; - } + function isPinnedOrTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && + currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { + return true; } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments); - emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment); - } - } - function writeDeclarationFile(jsFilePath, sourceFile) { - var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput; - var appliedSyncOutputPos = 0; - ts.forEach(emitDeclarationResult.aliasDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += aliasEmitInfo.asynchronousOutput; - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos); - writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); if (compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); } } } ts.emitFiles = emitFiles; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { + ts.programTime = 0; ts.emitTime = 0; ts.ioReadTime = 0; + ts.ioWriteTime = 0; ts.version = "1.5.0.0"; - function createCompilerHost(options) { + function findConfigFile(searchPath) { + var fileName = "tsconfig.json"; + while (true) { + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; function getCanonicalFileName(fileName) { @@ -22497,29 +23950,31 @@ var ts; } text = ""; } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined; + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } } function writeFile(fileName, data, writeByteOrderMark, onError) { - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } try { + var start = new Date().getTime(); ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); ts.sys.writeFile(fileName, data, writeByteOrderMark); + ts.ioWriteTime += new Date().getTime() - start; } catch (e) { if (onError) { @@ -22540,6 +23995,9 @@ var ts; ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program) { var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics()); + } return ts.sortAndDeduplicateDiagnostics(diagnostics); } ts.getPreEmitDiagnostics = getPreEmitDiagnostics; @@ -22573,14 +24031,16 @@ var ts; var diagnostics = ts.createDiagnosticCollection(); var seenNoDefaultLib = options.noLib; var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var start = new Date().getTime(); host = host || createCompilerHost(options); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); if (!seenNoDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; + ts.programTime += new Date().getTime() - start; program = { getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, @@ -22618,10 +24078,6 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function getDeclarationDiagnostics(targetSourceFile) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(targetSourceFile); - return ts.getDeclarationDiagnostics(getEmitHost(), resolver, targetSourceFile); - } function emit(sourceFile, writeFileCallback) { if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; @@ -22652,6 +24108,9 @@ var ts; function getSemanticDiagnostics(sourceFile) { return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); } + function getDeclarationDiagnostics(sourceFile) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + } function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } @@ -22663,6 +24122,13 @@ var ts; var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); } + function getDeclarationDiagnosticsForFile(sourceFile) { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + var writeFile = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + } + } function getGlobalDiagnostics() { var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; @@ -22678,10 +24144,10 @@ var ts; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var start; - var _length; + var length; if (refEnd !== undefined && refPos !== undefined) { start = refPos; - _length = refEnd - refPos; + length = refEnd - refPos; } var diagnostic; if (hasExtension(fileName)) { @@ -22706,7 +24172,7 @@ var ts; } if (diagnostic) { if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, start, _length, diagnostic, fileName)); + diagnostics.add(ts.createFileDiagnostic(refFile, start, length, diagnostic, fileName)); } else { diagnostics.add(ts.createCompilerDiagnostic(diagnostic, fileName)); @@ -22750,14 +24216,14 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var _file = filesByName[canonicalName]; - if (_file && host.useCaseSensitiveFileNames()) { - var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(_file.fileName, host.getCurrentDirectory()) : _file.fileName; + var file = filesByName[canonicalName]; + if (file && host.useCaseSensitiveFileNames()) { + var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } } - return _file; + return file; } } function processReferencedFiles(file, basePath) { @@ -22768,7 +24234,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 204 || node.kind === 203 || node.kind === 210) { + if (node.kind === 206 || node.kind === 205 || node.kind === 212) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -22788,17 +24254,17 @@ var ts; } } } - else if (node.kind === 200 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 202 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { - var _searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - var tsFile = findModuleSourceFile(_searchName + ".ts", nameLiteral); + var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); + var tsFile = findModuleSourceFile(searchName + ".ts", nameLiteral); if (!tsFile) { - findModuleSourceFile(_searchName + ".d.ts", nameLiteral); + findModuleSourceFile(searchName + ".d.ts", nameLiteral); } } } @@ -22819,10 +24285,16 @@ var ts; } return; } + var languageVersion = options.target || 0; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (firstExternalModuleSourceFile && !options.module) { - var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + if (!options.module && languageVersion < 2) { + var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + } + } + if (options.module && languageVersion >= 2) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); } if (options.outDir || options.sourceRoot || @@ -22871,6 +24343,10 @@ var ts; } ts.createProgram = createProgram; })(ts || (ts = {})); +/// +/// +/// +/// var ts; (function (ts) { ts.optionDeclarations = [ @@ -23221,6 +24697,20 @@ var ts; } ts.parseConfigFile = parseConfigFile; })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// var ts; (function (ts) { var OutliningElementsCollector; @@ -23240,7 +24730,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 161; + return ts.isFunctionBlock(node) && node.parent.kind !== 163; } var depth = 0; var maxDepth = 20; @@ -23249,30 +24739,30 @@ var ts; return; } switch (n.kind) { - case 174: + case 176: if (!ts.isFunctionBlock(n)) { - var _parent = n.parent; + var parent_6 = n.parent; var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (_parent.kind === 179 || - _parent.kind === 182 || - _parent.kind === 183 || - _parent.kind === 181 || - _parent.kind === 178 || - _parent.kind === 180 || - _parent.kind === 187 || - _parent.kind === 217) { - addOutliningSpan(_parent, openBrace, closeBrace, autoCollapse(n)); + if (parent_6.kind === 181 || + parent_6.kind === 184 || + parent_6.kind === 185 || + parent_6.kind === 183 || + parent_6.kind === 180 || + parent_6.kind === 182 || + parent_6.kind === 189 || + parent_6.kind === 220) { + addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } - if (_parent.kind === 191) { - var tryStatement = _parent; + if (parent_6.kind === 193) { + var tryStatement = parent_6; if (tryStatement.tryBlock === n) { - addOutliningSpan(_parent, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 80, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 81, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -23288,23 +24778,23 @@ var ts; }); break; } - case 201: { - var _openBrace = ts.findChildOfKind(n, 14, sourceFile); - var _closeBrace = ts.findChildOfKind(n, 15, sourceFile); - addOutliningSpan(n.parent, _openBrace, _closeBrace, autoCollapse(n)); + case 203: { + var openBrace = ts.findChildOfKind(n, 14, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 196: - case 197: + case 198: case 199: - case 152: - case 202: { - var _openBrace_1 = ts.findChildOfKind(n, 14, sourceFile); - var _closeBrace_1 = ts.findChildOfKind(n, 15, sourceFile); - addOutliningSpan(n, _openBrace_1, _closeBrace_1, autoCollapse(n)); + case 201: + case 154: + case 204: { + var openBrace = ts.findChildOfKind(n, 14, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 151: + case 153: var openBracket = ts.findChildOfKind(n, 18, sourceFile); var closeBracket = ts.findChildOfKind(n, 19, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -23375,9 +24865,9 @@ var ts; if (result !== undefined) { return result; } - if (declaration.name.kind === 126) { + if (declaration.name.kind === 127) { var expr = declaration.name.expression; - if (expr.kind === 153) { + if (expr.kind === 155) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -23385,7 +24875,7 @@ var ts; return undefined; } function getTextOfIdentifierOrLiteral(node) { - if (node.kind === 64 || + if (node.kind === 65 || node.kind === 8 || node.kind === 7) { return node.text; @@ -23398,7 +24888,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 126) { + else if (declaration.name.kind === 127) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -23415,7 +24905,7 @@ var ts; } return true; } - if (expression.kind === 153) { + if (expression.kind === 155) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -23426,7 +24916,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 126) { + if (declaration.name.kind === 127) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -23442,15 +24932,15 @@ var ts; } function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); - var _bestMatchKind = 3; + var bestMatchKind = ts.PatternMatchKind.camelCase; for (var _i = 0, _n = matches.length; _i < _n; _i++) { var match = matches[_i]; var kind = match.kind; - if (kind < _bestMatchKind) { - _bestMatchKind = kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; } } - return _bestMatchKind; + return bestMatchKind; } var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { @@ -23477,6 +24967,7 @@ var ts; NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { var NavigationBar; @@ -23489,14 +24980,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 200: + case 202: do { current = current.parent; - } while (current.kind === 200); - case 196: + } while (current.kind === 202); + case 198: + case 201: case 199: case 197: - case 195: indent++; } current = current.parent; @@ -23507,26 +24998,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 175: + case 177: ts.forEach(node.declarationList.declarations, visit); break; - case 148: - case 149: + case 150: + case 151: ts.forEach(node.elements, visit); break; - case 210: + case 212: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 204: + case 206: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { childNodes.push(importClause.namedBindings); } else { @@ -23535,20 +25026,20 @@ var ts; } } break; - case 150: - case 193: + case 152: + case 195: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 196: + case 198: + case 201: case 199: + case 202: case 197: - case 200: - case 195: - case 203: - case 208: - case 212: + case 205: + case 210: + case 214: childNodes.push(node); break; } @@ -23583,17 +25074,17 @@ var ts; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var node = nodes[_i]; switch (node.kind) { - case 196: + case 198: + case 201: case 199: - case 197: topLevelNodes.push(node); break; - case 200: + case 202: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 195: + case 197: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -23604,9 +25095,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 195) { - if (functionDeclaration.body && functionDeclaration.body.kind === 174) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 195 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 197) { + if (functionDeclaration.body && functionDeclaration.body.kind === 176) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 197 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -23621,17 +25112,17 @@ var ts; var keyToItem = {}; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var child = nodes[_i]; - var _item = createItem(child); - if (_item !== undefined) { - if (_item.text.length > 0) { - var key = _item.text + "-" + _item.kind + "-" + _item.indent; + var item_3 = createItem(child); + if (item_3 !== undefined) { + if (item_3.text.length > 0) { + var key = item_3.text + "-" + item_3.kind + "-" + item_3.indent; var itemWithSameName = keyToItem[key]; if (itemWithSameName) { - merge(itemWithSameName, _item); + merge(itemWithSameName, item_3); } else { - keyToItem[key] = _item; - items.push(_item); + keyToItem[key] = item_3; + items.push(item_3); } } } @@ -23659,7 +25150,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 128: + case 129: if (ts.isBindingPattern(node.name)) { break; } @@ -23667,34 +25158,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 134: + case 133: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 136: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 137: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 140: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 223: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 138: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 139: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); case 132: case 131: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 134: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 135: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 138: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 220: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 136: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 137: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 130: - case 129: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 195: + case 197: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 193: - case 150: + case 195: + case 152: var variableDeclarationNode; - var _name; - if (node.kind === 150) { - _name = node.name; + var name_18; + if (node.kind === 152) { + name_18 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 193) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 195) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -23702,24 +25193,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - _name = node.name; + name_18 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(_name), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_18), ts.ScriptElementKind.variableElement); } - case 133: + case 135: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 212: - case 208: - case 203: + case 214: + case 210: case 205: - case 206: + case 207: + case 208: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -23749,17 +25240,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 221: + case 224: return createSourceFileItem(node); - case 196: + case 198: return createClassItem(node); - case 199: + case 201: return createEnumItem(node); - case 197: + case 199: return createIterfaceItem(node); - case 200: + case 202: return createModuleItem(node); - case 195: + case 197: return createFunctionItem(node); } return undefined; @@ -23769,7 +25260,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 200) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 202) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -23781,9 +25272,9 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.name && node.body && node.body.kind === 174) { + if ((node.name || node.flags & 256) && node.body && node.body.kind === 176) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + return getNavigationBarItem((!node.name && node.flags & 256) ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } return undefined; } @@ -23799,13 +25290,10 @@ var ts; return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); } function createClassItem(node) { - if (!node.name) { - return undefined; - } var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 133 && member; + return member.kind === 135 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -23813,7 +25301,8 @@ var ts; } childItems = getItemsWorker(sortNodes(nodes), createChildItem); } - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + var nodeName = !node.name && (node.flags & 256) ? "default" : node.name.text; + return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createEnumItem(node) { var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); @@ -23825,19 +25314,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 126; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 127; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 200) { + while (node.body.kind === 202) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 221 + return node.kind === 224 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -23919,10 +25408,10 @@ var ts; var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); if (index === 0) { if (chunk.text.length === candidate.length) { - return createPatternMatch(0, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); } else { - return createPatternMatch(1, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -23932,14 +25421,14 @@ var ts; for (var _i = 0, _n = wordSpans.length; _i < _n; _i++) { var span = wordSpans[_i]; if (partStartsWith(candidate, span, chunk.text, true)) { - return createPatternMatch(2, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); } } } } else { if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(2, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); } } if (!isLowercase) { @@ -23947,18 +25436,18 @@ var ts; var candidateParts = getWordSpans(candidate); var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); if (camelCaseWeight !== undefined) { - return createPatternMatch(3, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); } camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); if (camelCaseWeight !== undefined) { - return createPatternMatch(3, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); } } } if (isLowercase) { if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(2, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); } } } @@ -24009,10 +25498,10 @@ var ts; } } else { - for (var _i = 0; _i < patternPartLength; _i++) { - var _ch1 = pattern.charCodeAt(patternPartStart + _i); - var _ch2 = candidate.charCodeAt(candidateSpan.start + _i); - if (_ch1 !== _ch2) { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (ch1 !== ch2) { return false; } } @@ -24087,7 +25576,7 @@ var ts; return result1.kind - result2.kind; } function compareCamelCase(result1, result2) { - if (result1.kind === 3 && result2.kind === 3) { + if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { return result2.camelCaseWeight - result1.camelCaseWeight; } return 0; @@ -24299,6 +25788,7 @@ var ts; return transition; } })(ts || (ts = {})); +/// var ts; (function (ts) { var SignatureHelp; @@ -24329,7 +25819,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 155 || node.parent.kind === 156) { + if (node.parent.kind === 157 || node.parent.kind === 158) { var callExpression = node.parent; if (node.kind === 24 || node.kind === 16) { @@ -24346,43 +25836,43 @@ var ts; } var listItemInfo = ts.findListItemInfo(node); if (listItemInfo) { - var _list = listItemInfo.list; - var _isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === _list.pos; - var argumentIndex = getArgumentIndex(_list, node); - var argumentCount = getArgumentCount(_list); + var list = listItemInfo.list; + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + var argumentIndex = getArgumentIndex(list, node); + var argumentCount = getArgumentCount(list); ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); return { - kind: _isTypeArgList ? 0 : 1, + kind: isTypeArgList ? 0 : 1, invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(_list), + argumentsSpan: getApplicableSpanForArguments(list), argumentIndex: argumentIndex, argumentCount: argumentCount }; } } - else if (node.kind === 10 && node.parent.kind === 157) { + else if (node.kind === 10 && node.parent.kind === 159) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 157) { + else if (node.kind === 11 && node.parent.parent.kind === 159) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 169); - var _argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; - return getArgumentListInfoForTemplate(tagExpression, _argumentIndex); + ts.Debug.assert(templateExpression.kind === 171); + var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 173 && node.parent.parent.parent.kind === 157) { + else if (node.parent.kind === 175 && node.parent.parent.parent.kind === 159) { var templateSpan = node.parent; - var _templateExpression = templateSpan.parent; - var _tagExpression = _templateExpression.parent; - ts.Debug.assert(_templateExpression.kind === 169); + var templateExpression = templateSpan.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 171); if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } - var spanIndex = _templateExpression.templateSpans.indexOf(templateSpan); - var _argumentIndex_1 = getArgumentIndexForTemplatePiece(spanIndex, node); - return getArgumentListInfoForTemplate(_tagExpression, _argumentIndex_1); + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } return undefined; } @@ -24440,7 +25930,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 169) { + if (template.kind === 171) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -24449,16 +25939,16 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 221; n = n.parent) { + for (var n = node; n.kind !== 224; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } if (n.pos < n.parent.pos || n.end > n.parent.end) { ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); } - var _argumentInfo = getImmediatelyContainingArgumentInfo(n); - if (_argumentInfo) { - return _argumentInfo; + var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); + if (argumentInfo_1) { + return argumentInfo_1; } } return undefined; @@ -24621,6 +26111,129 @@ var ts; return start < end; } ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + ts.positionBelongsToNode = positionBelongsToNode; + function isCompletedNode(n, sourceFile) { + if (ts.nodeIsMissing(n)) { + return false; + } + switch (n.kind) { + case 198: + case 199: + case 201: + case 154: + case 150: + case 145: + case 176: + case 203: + case 204: + return nodeEndsWith(n, 15, sourceFile); + case 220: + return isCompletedNode(n.block, sourceFile); + case 158: + if (!n.arguments) { + return true; + } + case 157: + case 161: + case 149: + return nodeEndsWith(n, 17, sourceFile); + case 142: + case 143: + return isCompletedNode(n.type, sourceFile); + case 135: + case 136: + case 137: + case 197: + case 162: + case 134: + case 133: + case 139: + case 138: + case 163: + if (n.body) { + return isCompletedNode(n.body, sourceFile); + } + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 17, sourceFile); + case 202: + return n.body && isCompletedNode(n.body, sourceFile); + case 180: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); + } + return isCompletedNode(n.thenStatement, sourceFile); + case 179: + return isCompletedNode(n.expression, sourceFile); + case 153: + case 151: + case 156: + case 127: + case 147: + return nodeEndsWith(n, 19, sourceFile); + case 140: + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 19, sourceFile); + case 217: + case 218: + return false; + case 183: + case 184: + case 185: + case 182: + return isCompletedNode(n.statement, sourceFile); + case 181: + var hasWhileKeyword = findChildOfKind(n, 100, sourceFile); + if (hasWhileKeyword) { + return nodeEndsWith(n, 17, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + case 144: + return isCompletedNode(n.exprName, sourceFile); + case 165: + case 164: + case 166: + case 172: + case 173: + var unaryWordExpression = n; + return isCompletedNode(unaryWordExpression.expression, sourceFile); + case 159: + return isCompletedNode(n.template, sourceFile); + case 171: + var lastSpan = ts.lastOrUndefined(n.templateSpans); + return isCompletedNode(lastSpan, sourceFile); + case 175: + return ts.nodeIsPresent(n.literal); + case 167: + return isCompletedNode(n.operand, sourceFile); + case 169: + return isCompletedNode(n.right, sourceFile); + case 170: + return isCompletedNode(n.whenFalse, sourceFile); + default: + return true; + } + } + ts.isCompletedNode = isCompletedNode; + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = children[children.length - 1]; + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 22 && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } function findListItemInfo(node) { var list = findContainingList(node); if (!list) { @@ -24634,13 +26247,17 @@ var ts; }; } ts.findListItemInfo = findListItemInfo; + function hasChildOfKind(n, kind, sourceFile) { + return !!findChildOfKind(n, kind, sourceFile); + } + ts.hasChildOfKind = hasChildOfKind; function findChildOfKind(n, kind, sourceFile) { return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); } ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 222 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 225 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -24746,10 +26363,10 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 221); + ts.Debug.assert(startNode !== undefined || n.kind === 224); if (children.length) { - var _candidate = findRightmostChildNodeWithTokens(children, children.length); - return _candidate && findRightmostToken(_candidate); + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); } } function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { @@ -24783,22 +26400,23 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 139 || node.kind === 155) { + if (node.kind === 141 || node.kind === 157) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 196 || node.kind === 197) { + if (ts.isFunctionLike(node) || node.kind === 198 || node.kind === 199) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 124; + return n.kind >= 0 && n.kind <= 125; } ts.isToken = isToken; function isWord(kind) { - return kind === 64 || ts.isKeyword(kind); + return kind === 65 || ts.isKeyword(kind); } + ts.isWord = isWord; function isPropertyName(kind) { return kind === 8 || kind === 7 || isWord(kind); } @@ -24807,7 +26425,7 @@ var ts; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 <= kind && kind <= 63; + return 14 <= kind && kind <= 64; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -24815,6 +26433,16 @@ var ts; && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; + function isAccessibilityModifier(kind) { + switch (kind) { + case 109: + case 107: + case 108: + return true; + } + return false; + } + ts.isAccessibilityModifier = isAccessibilityModifier; function compareDataObjects(dst, src) { for (var e in dst) { if (typeof dst[e] === "object") { @@ -24835,7 +26463,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 128; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 129; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -24846,12 +26474,12 @@ var ts; resetWriter(); return { displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, 5); }, - writeOperator: function (text) { return writeKind(text, 12); }, - writePunctuation: function (text) { return writeKind(text, 15); }, - writeSpace: function (text) { return writeKind(text, 16); }, - writeStringLiteral: function (text) { return writeKind(text, 8); }, - writeParameter: function (text) { return writeKind(text, 13); }, + writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, + writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, + writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, + writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, + writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, writeSymbol: writeSymbol, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -24863,7 +26491,7 @@ var ts; if (lineStart) { var indentString = ts.getIndentString(indent); if (indentString) { - displayParts.push(displayPart(indentString, 16)); + displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); } lineStart = false; } @@ -24891,48 +26519,48 @@ var ts; function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3) { - return isFirstDeclarationOfSymbolParameter(symbol) ? 13 : 9; + return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } else if (flags & 4) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 32768) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 65536) { - return 14; + return ts.SymbolDisplayPartKind.propertyName; } else if (flags & 8) { - return 19; + return ts.SymbolDisplayPartKind.enumMemberName; } else if (flags & 16) { - return 20; + return ts.SymbolDisplayPartKind.functionName; } else if (flags & 32) { - return 1; + return ts.SymbolDisplayPartKind.className; } else if (flags & 64) { - return 4; + return ts.SymbolDisplayPartKind.interfaceName; } else if (flags & 384) { - return 2; + return ts.SymbolDisplayPartKind.enumName; } else if (flags & 1536) { - return 11; + return ts.SymbolDisplayPartKind.moduleName; } else if (flags & 8192) { - return 10; + return ts.SymbolDisplayPartKind.methodName; } else if (flags & 262144) { - return 18; + return ts.SymbolDisplayPartKind.typeParameterName; } else if (flags & 524288) { - return 0; + return ts.SymbolDisplayPartKind.aliasName; } else if (flags & 8388608) { - return 0; + return ts.SymbolDisplayPartKind.aliasName; } - return 17; + return ts.SymbolDisplayPartKind.text; } } ts.symbolPart = symbolPart; @@ -24944,27 +26572,34 @@ var ts; } ts.displayPart = displayPart; function spacePart() { - return displayPart(" ", 16); + return displayPart(" ", ts.SymbolDisplayPartKind.space); } ts.spacePart = spacePart; function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), 5); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); } ts.keywordPart = keywordPart; function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), 15); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); } ts.punctuationPart = punctuationPart; function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), 12); + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); } ts.operatorPart = operatorPart; + function textOrKeywordPart(text) { + var kind = ts.stringToToken(text); + return kind === undefined + ? textPart(text) + : keywordPart(kind); + } + ts.textOrKeywordPart = textOrKeywordPart; function textPart(text) { - return displayPart(text, 17); + return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; function lineBreakPart() { - return displayPart("\n", 6); + return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } ts.lineBreakPart = lineBreakPart; function mapToDisplayParts(writeDisplayParts) { @@ -24993,6 +26628,8 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; })(ts || (ts = {})); +/// +/// var ts; (function (ts) { var formatting; @@ -25044,21 +26681,21 @@ var ts; var t; var pos = scanner.getStartPos(); while (pos < endPos) { - var _t = scanner.getToken(); - if (!ts.isTrivia(_t)) { + var t_2 = scanner.getToken(); + if (!ts.isTrivia(t_2)) { break; } scanner.scan(); - var _item = { + var item_4 = { pos: pos, end: scanner.getStartPos(), - kind: _t + kind: t_2 }; pos = scanner.getStartPos(); if (!leadingTrivia) { leadingTrivia = []; } - leadingTrivia.push(_item); + leadingTrivia.push(item_4); } savedPos = scanner.getStartPos(); } @@ -25066,8 +26703,8 @@ var ts; if (node) { switch (node.kind) { case 27: - case 59: case 60: + case 61: case 42: case 41: return true; @@ -25083,7 +26720,7 @@ var ts; container.kind === 13; } function startsWithSlashToken(t) { - return t === 36 || t === 56; + return t === 36 || t === 57; } function readTokenInfo(n) { if (!isOnToken()) { @@ -25162,8 +26799,8 @@ var ts; } function isOnToken() { var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var _startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); - return _startPos < endPos && current !== 1 && !ts.isTrivia(current); + var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + return startPos < endPos && current !== 1 && !ts.isTrivia(current); } function fixTokenKind(tokenInfo, container) { if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { @@ -25175,6 +26812,21 @@ var ts; formatting.getFormattingScanner = getFormattingScanner; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25253,6 +26905,21 @@ var ts; formatting.FormattingContext = FormattingContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25267,6 +26934,21 @@ var ts; var FormattingRequestKind = formatting.FormattingRequestKind; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25288,6 +26970,21 @@ var ts; formatting.Rule = Rule; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25301,6 +26998,21 @@ var ts; var RuleAction = formatting.RuleAction; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25331,6 +27043,21 @@ var ts; formatting.RuleDescriptor = RuleDescriptor; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25342,6 +27069,21 @@ var ts; var RuleFlags = formatting.RuleFlags; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25369,6 +27111,21 @@ var ts; formatting.RuleOperation = RuleOperation; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25402,12 +27159,30 @@ var ts; formatting.RuleOperationContext = RuleOperationContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; (function (formatting) { var Rules = (function () { function Rules() { + /// + /// Common Rules + /// this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -25418,8 +27193,8 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(50, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 75), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 99), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 76), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 100), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.FromTokens([17, 19, 23, 22])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -25429,9 +27204,9 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([64, 3]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([65, 3]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 74, 95, 80, 75]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 75, 96, 81, 76]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); @@ -25450,25 +27225,25 @@ var ts; this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(34, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([97, 93, 87, 73, 89, 96]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104, 69]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98, 94, 88, 74, 90, 97]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105, 70]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(82, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(98, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(89, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 74, 75, 66]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([95, 80]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([115, 119]), 64), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(99, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 75, 76, 67]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96, 81]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 120]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(113, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 117]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([68, 114, 76, 77, 78, 115, 102, 84, 103, 116, 106, 108, 119, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([78, 102])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117, 118]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 103, 85, 104, 117, 107, 109, 120, 110]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 103])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 64), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(50, formatting.Shared.TokenRange.FromTokens([17, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); @@ -25541,42 +27316,42 @@ var ts; this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(82, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(82, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var _name in o) { - if (o[_name] === rule) { - return _name; + for (var name_19 in o) { + if (o[name_19] === rule) { + return name_19; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 183; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 167: - case 168: + case 169: + case 170: return true; - case 203: - case 193: - case 128: - case 220: - case 130: + case 205: + case 195: case 129: - return context.currentTokenSpan.kind === 52 || context.nextTokenSpan.kind === 52; - case 182: - return context.currentTokenSpan.kind === 85 || context.nextTokenSpan.kind === 85; - case 183: - return context.currentTokenSpan.kind === 124 || context.nextTokenSpan.kind === 124; - case 150: - return context.currentTokenSpan.kind === 52 || context.nextTokenSpan.kind === 52; + case 223: + case 132: + case 131: + return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; + case 184: + return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; + case 185: + return context.currentTokenSpan.kind === 125 || context.nextTokenSpan.kind === 125; + case 152: + return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; } return false; }; @@ -25584,9 +27359,25 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 168; + return context.contextNode.kind === 170; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { + //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. + //// + //// Ex: + //// if (1) { .... + //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context + //// + //// Ex: + //// if (1) + //// { ... } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. + //// + //// Ex: + //// if (1) + //// { ... + //// } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { @@ -25609,26 +27400,26 @@ var ts; return true; } switch (node.kind) { - case 174: - case 202: - case 152: - case 201: + case 176: + case 204: + case 154: + case 203: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 195: - case 132: - case 131: - case 134: - case 135: - case 136: - case 160: - case 133: - case 161: case 197: + case 134: + case 133: + case 136: + case 137: + case 138: + case 162: + case 135: + case 163: + case 199: return true; } return false; @@ -25638,53 +27429,53 @@ var ts; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 196: - case 197: + case 198: case 199: - case 143: - case 200: + case 201: + case 145: + case 202: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 196: - case 200: - case 199: - case 174: - case 217: + case 198: + case 202: case 201: - case 188: + case 176: + case 220: + case 203: + case 190: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 178: - case 188: - case 181: - case 182: - case 183: case 180: - case 191: - case 179: - case 187: - case 217: + case 190: + case 183: + case 184: + case 185: + case 182: + case 193: + case 181: + case 189: + case 220: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 152; + return context.contextNode.kind === 154; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 155; + return context.contextNode.kind === 157; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 156; + return context.contextNode.kind === 158; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -25696,35 +27487,35 @@ var ts; return context.TokensAreOnSameLine(); }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 194 && + return context.currentTokenParent.kind === 196 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind != 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 200; + return context.contextNode.kind === 202; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 143; + return context.contextNode.kind === 145; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 && token.kind !== 25) { return false; } switch (parent.kind) { - case 139: - case 196: + case 141: + case 198: + case 199: case 197: - case 195: - case 160: - case 161: - case 132: - case 131: - case 136: - case 137: - case 155: - case 156: + case 162: + case 163: + case 134: + case 133: + case 138: + case 139: + case 157: + case 158: return true; default: return false; @@ -25735,13 +27526,28 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 98 && context.currentTokenParent.kind === 164; + return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 166; }; return Rules; })(); formatting.Rules = Rules; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25757,7 +27563,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 124 + 1; + this.mapRowLength = 125 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -25852,7 +27658,7 @@ var ts; var position; if (rule.Operation.Action == 1) { position = specificTokens ? - 0 : + RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; } else if (!rule.Operation.Context.IsAny()) { @@ -25878,6 +27684,21 @@ var ts; formatting.RulesBucket = RulesBucket; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -25933,7 +27754,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 124; token++) { + for (var token = 0; token <= 125; token++) { result.push(token); } return result; @@ -25975,23 +27796,64 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(65, 124); - TokenRange.BinaryOperators = TokenRange.FromRange(24, 63); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([85, 86, 124]); + TokenRange.Keywords = TokenRange.FromRange(66, 125); + TokenRange.BinaryOperators = TokenRange.FromRange(24, 64); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38, 39, 47, 46]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 64, 16, 18, 14, 92, 87]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([64, 16, 92, 87]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([64, 17, 19, 87]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([64, 16, 92, 87]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([64, 17, 19, 87]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 65, 16, 18, 14, 93, 88]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([64, 118, 120, 112, 121, 98, 111]); + TokenRange.TypeNames = TokenRange.FromTokens([65, 119, 121, 113, 122, 99, 112]); return TokenRange; })(); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var ts; (function (ts) { var formatting; @@ -26077,6 +27939,10 @@ var ts; formatting.RulesProvider = RulesProvider; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// +/// +/// +/// var ts; (function (ts) { var formatting; @@ -26122,13 +27988,13 @@ var ts; } formatting.formatSelection = formatSelection; function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { - var _parent = findOutermostParent(position, expectedLastToken, sourceFile); - if (!_parent) { + var parent = findOutermostParent(position, expectedLastToken, sourceFile); + if (!parent) { return []; } var span = { - pos: ts.getLineStartPositionForPosition(_parent.getStart(sourceFile), sourceFile), - end: _parent.end + pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), + end: parent.end }; return formatSpan(span, sourceFile, options, rulesProvider, requestKind); } @@ -26150,17 +28016,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 196: - case 197: + case 198: + case 199: return ts.rangeContainsRange(parent.members, node); - case 200: + case 202: var body = parent.body; - return body && body.kind === 174 && ts.rangeContainsRange(body.statements, node); - case 221: - case 174: - case 201: + return body && body.kind === 176 && ts.rangeContainsRange(body.statements, node); + case 224: + case 176: + case 203: return ts.rangeContainsRange(parent.statements, node); - case 217: + case 220: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -26265,10 +28131,10 @@ var ts; } } else { - var _startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; + var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); - if (_startLine !== parentStartLine || startPos === column) { + if (startLine !== parentStartLine || startPos === column) { return column; } } @@ -26279,9 +28145,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 221 || - parent.kind === 214 || - parent.kind === 215) { + parent.kind === 224 || + parent.kind === 217 || + parent.kind === 218) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -26307,6 +28173,26 @@ var ts; delta: delta }; } + function getFirstNonDecoratorTokenOfNode(node) { + if (node.modifiers && node.modifiers.length) { + return node.modifiers[0].kind; + } + switch (node.kind) { + case 198: return 69; + case 199: return 104; + case 197: return 83; + case 201: return 201; + case 136: return 116; + case 137: return 120; + case 134: + if (node.asteriskToken) { + return 35; + } + case 132: + case 129: + return node.name.kind; + } + } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { return { getIndentationForComment: function (kind) { @@ -26318,13 +28204,19 @@ var ts; return indentation; }, getIndentationForToken: function (line, kind) { + if (nodeStartLine !== line && node.decorators) { + if (kind === getFirstNonDecoratorTokenOfNode(node)) { + return indentation; + } + } switch (kind) { case 14: case 15: case 18: case 19: - case 75: - case 99: + case 76: + case 100: + case 52: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -26385,19 +28277,19 @@ var ts; return inheritedIndentation; } while (formattingScanner.isOnToken()) { - var _tokenInfo = formattingScanner.readTokenInfo(node); - if (_tokenInfo.token.end > childStartPos) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(_tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; } if (ts.isToken(child)) { - var _tokenInfo_1 = formattingScanner.readTokenInfo(child); - ts.Debug.assert(_tokenInfo_1.token.end === child.end); - consumeTokenAndAdvanceScanner(_tokenInfo_1, node, parentDynamicIndentation); + var tokenInfo = formattingScanner.readTokenInfo(child); + ts.Debug.assert(tokenInfo.token.end === child.end); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } var childIndentation = computeIndentation(child, childStart.line, childIndentationAmount, node, parentDynamicIndentation, parentStartLine); @@ -26409,34 +28301,34 @@ var ts; var listStartToken = getOpenTokenForList(parent, nodes); var listEndToken = getCloseTokenForOpenToken(listStartToken); var listDynamicIndentation = parentDynamicIndentation; - var _startLine = parentStartLine; + var startLine = parentStartLine; if (listStartToken !== 0) { while (formattingScanner.isOnToken()) { - var _tokenInfo = formattingScanner.readTokenInfo(parent); - if (_tokenInfo.token.end > nodes.pos) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.end > nodes.pos) { break; } - else if (_tokenInfo.token.kind === listStartToken) { - _startLine = sourceFile.getLineAndCharacterOfPosition(_tokenInfo.token.pos).line; - var _indentation = computeIndentation(_tokenInfo.token, _startLine, -1, parent, parentDynamicIndentation, _startLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, _indentation.indentation, _indentation.delta); - consumeTokenAndAdvanceScanner(_tokenInfo, parent, listDynamicIndentation); + else if (tokenInfo.token.kind === listStartToken) { + startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, startLine); + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } else { - consumeTokenAndAdvanceScanner(_tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); } } } var inheritedIndentation = -1; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, _startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, true); } if (listEndToken !== 0) { if (formattingScanner.isOnToken()) { - var _tokenInfo_1 = formattingScanner.readTokenInfo(parent); - if (_tokenInfo_1.token.kind === listEndToken && ts.rangeContainsRange(parent, _tokenInfo_1.token)) { - consumeTokenAndAdvanceScanner(_tokenInfo_1, parent, listDynamicIndentation); + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } } } @@ -26487,8 +28379,8 @@ var ts; break; case 2: if (indentNextTokenOrTrivia) { - var _commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, _commentIndentation, false); + var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); + insertIndentation(triviaItem.pos, commentIndentation_1, false); indentNextTokenOrTrivia = false; } break; @@ -26580,10 +28472,10 @@ var ts; } } function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { - var _startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; + var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; var parts; - if (_startLine === endLine) { + if (startLine === endLine) { if (!firstLineIsIndented) { insertIndentation(commentRange.pos, indentation, false); } @@ -26592,14 +28484,14 @@ var ts; else { parts = []; var startPos = commentRange.pos; - for (var line = _startLine; line < endLine; ++line) { + for (var line = startLine; line < endLine; ++line) { var endOfLine = ts.getEndLinePosition(line, sourceFile); parts.push({ pos: startPos, end: endOfLine }); startPos = ts.getStartPositionOfLine(line + 1, sourceFile); } parts.push({ pos: startPos, end: commentRange.end }); } - var startLinePos = ts.getStartPositionOfLine(_startLine, sourceFile); + var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); if (indentation === nonWhitespaceColumnInFirstPart.column) { return; @@ -26607,21 +28499,21 @@ var ts; var startIndex = 0; if (firstLineIsIndented) { startIndex = 1; - _startLine++; + startLine++; } - var _delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; ++i, ++_startLine) { - var _startLinePos = ts.getStartPositionOfLine(_startLine, sourceFile); + var delta = indentation - nonWhitespaceColumnInFirstPart.column; + for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { + var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - var newIndentation = nonWhitespaceCharacterAndColumn.column + _delta; + var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; if (newIndentation > 0) { var indentationString = getIndentationString(newIndentation, options); - recordReplace(_startLinePos, nonWhitespaceCharacterAndColumn.character, indentationString); + recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); } else { - recordDelete(_startLinePos, nonWhitespaceCharacterAndColumn.character); + recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); } } } @@ -26688,20 +28580,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 174: - case 201: + case 176: + case 203: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 135: + case 197: + case 162: + case 134: case 133: - case 195: - case 160: - case 132: - case 131: - case 161: + case 163: if (node.typeParameters === list) { return 24; } @@ -26709,8 +28601,8 @@ var ts; return 16; } break; - case 155: - case 156: + case 157: + case 158: if (node.typeArguments === list) { return 24; } @@ -26718,7 +28610,7 @@ var ts; return 16; } break; - case 139: + case 141: if (node.typeArguments === list) { return 24; } @@ -26734,9 +28626,15 @@ var ts; } return 0; } + var internedSizes; var internedTabsIndentation; var internedSpacesIndentation; function getIndentationString(indentation, options) { + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + if (resetInternedStrings) { + internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; + } if (!options.ConvertTabsToSpaces) { var tabs = Math.floor(indentation / options.TabSize); var spaces = indentation - tabs * options.TabSize; @@ -26779,6 +28677,7 @@ var ts; formatting.getIndentationString = getIndentationString; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// var ts; (function (ts) { var formatting; @@ -26807,7 +28706,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 167) { + if (precedingToken.kind === 23 && precedingToken.parent.kind !== 169) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -26818,7 +28717,7 @@ var ts; var currentStart; var indentationDelta; while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0)) { + if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { indentationDelta = 0; @@ -26828,9 +28727,9 @@ var ts; } break; } - var _actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (_actualIndentation !== -1) { - return _actualIndentation; + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; } previous = current; current = current.parent; @@ -26847,9 +28746,9 @@ var ts; } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var _parent = current.parent; + var parent = current.parent; var parentStart; - while (_parent) { + while (parent) { var useActualIndentation = true; if (ignoreActualIndentationRange) { var start = current.getStart(sourceFile); @@ -26861,21 +28760,21 @@ var ts; return actualIndentation + indentationDelta; } } - parentStart = getParentStart(_parent, current, sourceFile); + parentStart = getParentStart(parent, current, sourceFile); var parentAndChildShareLine = parentStart.line === currentStart.line || - childStartsOnTheSameLineWithElseInIfStatement(_parent, current, currentStart.line, sourceFile); + childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { - var _actualIndentation = getActualIndentationForNode(current, _parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (_actualIndentation !== -1) { - return _actualIndentation + indentationDelta; + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; } } - if (shouldIndentChildNode(_parent.kind, current.kind) && !parentAndChildShareLine) { + if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { indentationDelta += options.IndentSize; } - current = _parent; + current = parent; currentStart = parentStart; - _parent = current.parent; + parent = current.parent; } return indentationDelta; } @@ -26897,7 +28796,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 221 || !parentAndChildShareLine); + (parent.kind === 224 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -26920,12 +28819,9 @@ var ts; function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 178 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 75, sourceFile); + if (parent.kind === 180 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 76, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -26936,23 +28832,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 139: + case 141: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 152: + case 154: return node.parent.properties; - case 151: + case 153: return node.parent.elements; - case 195: - case 160: - case 161: - case 132: - case 131: - case 136: - case 137: { + case 197: + case 162: + case 163: + case 134: + case 133: + case 138: + case 139: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -26963,15 +28859,15 @@ var ts; } break; } - case 156: - case 155: { - var _start = node.getStart(sourceFile); + case 158: + case 157: { + var start = node.getStart(sourceFile); if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, _start, node.getEnd())) { + ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { return node.parent.typeArguments; } if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, _start, node.getEnd())) { + ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { return node.parent.arguments; } break; @@ -27033,25 +28929,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 196: - case 197: + case 198: case 199: - case 151: - case 174: case 201: - case 152: - case 143: - case 202: - case 215: - case 214: - case 159: - case 155: - case 156: - case 175: - case 193: - case 209: - case 186: - case 168: + case 153: + case 176: + case 203: + case 154: + case 145: + case 147: + case 204: + case 218: + case 217: + case 161: + case 157: + case 158: + case 177: + case 195: + case 211: + case 188: + case 170: + case 151: + case 150: return true; } return false; @@ -27061,106 +28960,46 @@ var ts; return true; } switch (parent) { - case 179: - case 180: - case 182: - case 183: case 181: - case 178: - case 195: - case 160: - case 132: - case 131: - case 161: - case 133: + case 182: + case 184: + case 185: + case 183: + case 180: + case 197: + case 162: case 134: + case 133: + case 138: + case 163: case 135: - return child !== 174; + case 136: + case 137: + return child !== 176; default: return false; } } SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = children[children.length - 1]; - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === 22 && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - function isCompletedNode(n, sourceFile) { - if (n.getFullWidth() === 0) { - return false; - } - switch (n.kind) { - case 196: - case 197: - case 199: - case 152: - case 174: - case 201: - case 202: - return nodeEndsWith(n, 15, sourceFile); - case 217: - return isCompletedNode(n.block, sourceFile); - case 159: - case 136: - case 155: - case 137: - return nodeEndsWith(n, 17, sourceFile); - case 195: - case 160: - case 132: - case 131: - case 161: - return !n.body || isCompletedNode(n.body, sourceFile); - case 200: - return n.body && isCompletedNode(n.body, sourceFile); - case 178: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); - } - return isCompletedNode(n.thenStatement, sourceFile); - case 177: - return isCompletedNode(n.expression, sourceFile); - case 151: - return nodeEndsWith(n, 19, sourceFile); - case 214: - case 215: - return false; - case 181: - return isCompletedNode(n.statement, sourceFile); - case 182: - return isCompletedNode(n.statement, sourceFile); - case 183: - return isCompletedNode(n.statement, sourceFile); - case 180: - return isCompletedNode(n.statement, sourceFile); - case 179: - var hasWhileKeyword = ts.findChildOfKind(n, 99, sourceFile); - if (hasWhileKeyword) { - return nodeEndsWith(n, 17, sourceFile); - } - return isCompletedNode(n.statement, sourceFile); - default: - return true; - } - } })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/// var __extends = this.__extends || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }; +/// +/// +/// +/// +/// +/// +/// +/// +/// var ts; (function (ts) { ts.servicesVersion = "0.4"; @@ -27238,7 +29077,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(222, nodes.pos, nodes.end, 1024, this); + var list = createNode(225, nodes.pos, nodes.end, 1024, this); list._children = []; var pos = nodes.pos; for (var _i = 0, _n = nodes.length; _i < _n; _i++) { @@ -27257,7 +29096,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 125) { + if (this.kind >= 126) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -27302,7 +29141,7 @@ var ts; var children = this.getChildren(); for (var _i = 0, _n = children.length; _i < _n; _i++) { var child = children[_i]; - if (child.kind < 125) { + if (child.kind < 126) { return child; } return child.getFirstToken(sourceFile); @@ -27312,7 +29151,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 125) { + if (child.kind < 126) { return child; } return child.getLastToken(sourceFile); @@ -27358,7 +29197,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 128) { + if (canUseParsedParamTagComments && declaration.kind === 129) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -27366,13 +29205,13 @@ var ts; } }); } - if (declaration.kind === 200 && declaration.body.kind === 200) { + if (declaration.kind === 202 && declaration.body.kind === 202) { return; } - while (declaration.kind === 200 && declaration.parent.kind === 200) { + while (declaration.kind === 202 && declaration.parent.kind === 202) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 193 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 195 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -27417,13 +29256,14 @@ var ts; return isName(pos, end, sourceFile, paramTag); } function pushDocCommentLineText(docComments, text, blankLineCount) { - while (blankLineCount--) + while (blankLineCount--) { docComments.push(ts.textPart("")); + } docComments.push(ts.textPart(text)); } function getCleanedJsDocComment(pos, end, sourceFile) { var spacesToRemoveAfterAsterisk; - var _docComments = []; + var docComments = []; var blankLineCount = 0; var isInParamTag = false; while (pos < end) { @@ -27458,14 +29298,14 @@ var ts; } pos = consumeLineBreaks(pos, end, sourceFile); if (docCommentTextOfLine) { - pushDocCommentLineText(_docComments, docCommentTextOfLine, blankLineCount); + pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); blankLineCount = 0; } - else if (!isInParamTag && _docComments.length) { + else if (!isInParamTag && docComments.length) { blankLineCount++; } } - return _docComments; + return docComments; } function getCleanedParamJsDocComment(pos, end, sourceFile) { var paramHelpStringMargin; @@ -27566,8 +29406,8 @@ var ts; } var consumedSpaces = pos - startOfLinePos; if (consumedSpaces < paramHelpStringMargin) { - var _ch = sourceFile.text.charCodeAt(pos); - if (_ch === 42) { + var ch = sourceFile.text.charCodeAt(pos); + if (ch === 42) { pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); } } @@ -27656,9 +29496,9 @@ var ts; var namedDeclarations = []; ts.forEachChild(sourceFile, function visit(node) { switch (node.kind) { - case 195: - case 132: - case 131: + case 197: + case 134: + case 133: var functionDeclaration = node; if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) { var lastDeclaration = namedDeclarations.length > 0 ? @@ -27675,64 +29515,64 @@ var ts; ts.forEachChild(node, visit); } break; - case 196: - case 197: case 198: case 199: case 200: - case 203: - case 212: - case 208: - case 203: + case 201: + case 202: case 205: - case 206: - case 134: - case 135: - case 143: + case 214: + case 210: + case 205: + case 207: + case 208: + case 136: + case 137: + case 145: if (node.name) { namedDeclarations.push(node); } - case 133: - case 175: - case 194: - case 148: - case 149: - case 201: + case 135: + case 177: + case 196: + case 150: + case 151: + case 203: ts.forEachChild(node, visit); break; - case 174: + case 176: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 128: + case 129: if (!(node.flags & 112)) { break; } - case 193: - case 150: + case 195: + case 152: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 220: - case 130: - case 129: + case 223: + case 132: + case 131: namedDeclarations.push(node); break; - case 210: + case 212: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 204: + case 206: var importClause = node.importClause; if (importClause) { if (importClause.name) { namedDeclarations.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 206) { + if (importClause.namedBindings.kind === 208) { namedDeclarations.push(importClause.namedBindings); } else { @@ -27887,14 +29727,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 160) { + if (declaration.kind === 162) { return true; } - if (declaration.kind !== 193 && declaration.kind !== 195) { + if (declaration.kind !== 195 && declaration.kind !== 197) { return false; } - for (var _parent = declaration.parent; !ts.isFunctionBlock(_parent); _parent = _parent.parent) { - if (_parent.kind === 221 || _parent.kind === 201) { + for (var parent_7 = declaration.parent; !ts.isFunctionBlock(parent_7); parent_7 = parent_7.parent) { + if (parent_7.kind === 224 || parent_7.kind === 203) { return false; } } @@ -27996,17 +29836,17 @@ var ts; if (!scriptSnapshot) { throw new Error("Could not find file: '" + fileName + "'."); } - var _version = this.host.getScriptVersion(fileName); + var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, _version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true); } - else if (this.currentFileVersion !== _version) { + else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); - sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, _version, editRange); + sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); } if (sourceFile) { - this.currentFileVersion = _version; + this.currentFileVersion = version; this.currentFileName = fileName; this.currentFileScriptSnapshot = scriptSnapshot; this.currentSourceFile = sourceFile; @@ -28152,25 +29992,25 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1) { - if (token === 84) { + if (token === 85) { token = scanner.scan(); if (token === 8) { recordModuleName(); continue; } else { - if (token === 64) { + if (token === 65) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); continue; } } - else if (token === 52) { + else if (token === 53) { token = scanner.scan(); - if (token === 117) { + if (token === 118) { token = scanner.scan(); if (token === 16) { token = scanner.scan(); @@ -28195,7 +30035,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -28205,11 +30045,11 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 101) { + if (token === 102) { token = scanner.scan(); - if (token === 64) { + if (token === 65) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -28220,7 +30060,7 @@ var ts; } } } - else if (token === 77) { + else if (token === 78) { token = scanner.scan(); if (token === 14) { token = scanner.scan(); @@ -28229,7 +30069,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -28239,7 +30079,7 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 123) { + if (token === 124) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -28260,7 +30100,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 189 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 191 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -28268,17 +30108,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 64 && - (node.parent.kind === 185 || node.parent.kind === 184) && + return node.kind === 65 && + (node.parent.kind === 187 || node.parent.kind === 186) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 64 && - node.parent.kind === 189 && + return node.kind === 65 && + node.parent.kind === 191 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 189; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 191; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -28289,48 +30129,48 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 125 && node.parent.right === node; + return node.parent.kind === 126 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 153 && node.parent.name === node; + return node && node.parent && node.parent.kind === 155 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 155 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 157 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 156 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 158 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 200 && node.parent.name === node; + return node.parent.kind === 202 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 64 && + return node.kind === 65 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 64 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 218 || node.parent.kind === 219) && node.parent.name === node; + return (node.kind === 65 || node.kind === 8 || node.kind === 7) && + (node.parent.kind === 221 || node.parent.kind === 222) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 || node.kind === 7) { switch (node.parent.kind) { - case 130: - case 129: - case 218: - case 220: case 132: case 131: + case 221: + case 223: case 134: - case 135: - case 200: + case 133: + case 136: + case 137: + case 202: return node.parent.name === node; - case 154: + case 156: return node.parent.argumentExpression === node; } } @@ -28383,7 +30223,7 @@ var ts; BreakContinueSearchType[BreakContinueSearchType["All"] = 3] = "All"; })(BreakContinueSearchType || (BreakContinueSearchType = {})); var keywordCompletions = []; - for (var i = 65; i <= 124; i++) { + for (var i = 66; i <= 125; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -28397,17 +30237,17 @@ var ts; return undefined; } switch (node.kind) { - case 221: - case 132: - case 131: - case 195: - case 160: + case 224: case 134: - case 135: - case 196: + case 133: case 197: + case 162: + case 136: + case 137: + case 198: case 199: - case 200: + case 201: + case 202: return node; } } @@ -28415,38 +30255,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 200: return ScriptElementKind.moduleElement; - case 196: return ScriptElementKind.classElement; - case 197: return ScriptElementKind.interfaceElement; - case 198: return ScriptElementKind.typeElement; - case 199: return ScriptElementKind.enumElement; - case 193: + case 202: return ScriptElementKind.moduleElement; + case 198: return ScriptElementKind.classElement; + case 199: return ScriptElementKind.interfaceElement; + case 200: return ScriptElementKind.typeElement; + case 201: return ScriptElementKind.enumElement; + case 195: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 195: return ScriptElementKind.functionElement; - case 134: return ScriptElementKind.memberGetAccessorElement; - case 135: return ScriptElementKind.memberSetAccessorElement; + case 197: return ScriptElementKind.functionElement; + case 136: return ScriptElementKind.memberGetAccessorElement; + case 137: return ScriptElementKind.memberSetAccessorElement; + case 134: + case 133: + return ScriptElementKind.memberFunctionElement; case 132: case 131: - return ScriptElementKind.memberFunctionElement; - case 130: - case 129: return ScriptElementKind.memberVariableElement; - case 138: return ScriptElementKind.indexSignatureElement; - case 137: return ScriptElementKind.constructSignatureElement; - case 136: return ScriptElementKind.callSignatureElement; - case 133: return ScriptElementKind.constructorImplementationElement; - case 127: return ScriptElementKind.typeParameterElement; - case 220: return ScriptElementKind.variableElement; - case 128: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 203: - case 208: + case 140: return ScriptElementKind.indexSignatureElement; + case 139: return ScriptElementKind.constructSignatureElement; + case 138: return ScriptElementKind.callSignatureElement; + case 135: return ScriptElementKind.constructorImplementationElement; + case 128: return ScriptElementKind.typeParameterElement; + case 223: return ScriptElementKind.variableElement; + case 129: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 205: - case 212: - case 206: + case 210: + case 207: + case 214: + case 208: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -28460,7 +30300,6 @@ var ts; var typeInfoResolver; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - var activeCompletionSession; if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } @@ -28524,8 +30363,8 @@ var ts; return undefined; } if (!changesInCompilationSettingsAffectSyntax) { - var _oldSourceFile = program && program.getSourceFile(fileName); - if (_oldSourceFile) { + var oldSourceFile = program && program.getSourceFile(fileName); + if (oldSourceFile) { return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } } @@ -28542,9 +30381,9 @@ var ts; if (program.getSourceFiles().length !== rootFileNames.length) { return false; } - for (var _a = 0, _b = rootFileNames.length; _a < _b; _a++) { - var _fileName = rootFileNames[_a]; - if (!sourceFileUpToDate(program.getSourceFile(_fileName))) { + for (var _i = 0, _n = rootFileNames.length; _i < _n; _i++) { + var fileName = rootFileNames[_i]; + if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } } @@ -28579,35 +30418,42 @@ var ts; return semanticDiagnostics; } var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); - return semanticDiagnostics.concat(declarationDiagnostics); + return ts.concatenate(semanticDiagnostics, declarationDiagnostics); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); return program.getGlobalDiagnostics(); } - function getValidCompletionEntryDisplayName(symbol, target) { + function getCompletionEntryDisplayName(symbol, target, performCharacterChecks) { var displayName = symbol.getName(); - if (displayName && displayName.length > 0) { - var firstCharCode = displayName.charCodeAt(0); - if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { + if (!displayName) { + return undefined; + } + var firstCharCode = displayName.charCodeAt(0); + if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { + return undefined; + } + if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && + (firstCharCode === 39 || firstCharCode === 34)) { + displayName = displayName.substring(1, displayName.length - 1); + } + if (!displayName) { + return undefined; + } + if (performCharacterChecks) { + if (!ts.isIdentifierStart(displayName.charCodeAt(0), target)) { return undefined; } - if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && - (firstCharCode === 39 || firstCharCode === 34)) { - displayName = displayName.substring(1, displayName.length - 1); - } - var isValid = ts.isIdentifierStart(displayName.charCodeAt(0), target); - for (var _i = 1, n = displayName.length; isValid && _i < n; _i++) { - isValid = ts.isIdentifierPart(displayName.charCodeAt(_i), target); - } - if (isValid) { - return ts.unescapeIdentifier(displayName); + for (var i = 1, n = displayName.length; i < n; i++) { + if (!ts.isIdentifierPart(displayName.charCodeAt(i), target)) { + return undefined; + } } } - return undefined; + return ts.unescapeIdentifier(displayName); } function createCompletionEntry(symbol, typeChecker, location) { - var displayName = getValidCompletionEntryDisplayName(symbol, program.getCompilerOptions().target); + var displayName = getCompletionEntryDisplayName(symbol, program.getCompilerOptions().target, true); if (!displayName) { return undefined; } @@ -28617,63 +30463,53 @@ var ts; kindModifiers: getSymbolModifiers(symbol) }; } - function getCompletionsAtPosition(fileName, position) { - synchronizeHostData(); + function getCompletionData(fileName, position) { var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); - log("getCompletionsAtPosition: Get current token: " + (new Date().getTime() - start)); + log("getCompletionData: Get current token: " + (new Date().getTime() - start)); start = new Date().getTime(); var insideComment = isInsideComment(sourceFile, currentToken, position); - log("getCompletionsAtPosition: Is inside comment: " + (new Date().getTime() - start)); + log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { log("Returning an empty list because completion was inside a comment."); return undefined; } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); - log("getCompletionsAtPosition: Get previous token 1: " + (new Date().getTime() - start)); - if (previousToken && position <= previousToken.end && previousToken.kind === 64) { - var _start = new Date().getTime(); - previousToken = ts.findPrecedingToken(previousToken.pos, sourceFile); - log("getCompletionsAtPosition: Get previous token 2: " + (new Date().getTime() - _start)); + log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); + var contextToken = previousToken; + if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { + var start_1 = new Date().getTime(); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_1)); } - if (previousToken && isCompletionListBlocker(previousToken)) { + if (contextToken && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var node; - var isRightOfDot; - if (previousToken && previousToken.kind === 20 && previousToken.parent.kind === 153) { - node = previousToken.parent.expression; + var node = currentToken; + var isRightOfDot = false; + if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 155) { + node = contextToken.parent.expression; isRightOfDot = true; } - else if (previousToken && previousToken.kind === 20 && previousToken.parent.kind === 125) { - node = previousToken.parent.left; + else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 126) { + node = contextToken.parent.left; isRightOfDot = true; } - else { - node = currentToken; - isRightOfDot = false; - } - activeCompletionSession = { - fileName: fileName, - position: position, - entries: [], - symbols: {}, - typeChecker: typeInfoResolver - }; - log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart)); - var _location = ts.getTouchingPropertyName(sourceFile, position); + var location = ts.getTouchingPropertyName(sourceFile, position); + var target = program.getCompilerOptions().target; var semanticStart = new Date().getTime(); var isMemberCompletion; var isNewIdentifierLocation; + var symbols; if (isRightOfDot) { - var symbols = []; + symbols = []; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 64 || node.kind === 125 || node.kind === 153) { + if (node.kind === 65 || node.kind === 126 || node.kind === 155) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeInfoResolver.getAliasedSymbol(symbol); @@ -28694,10 +30530,9 @@ var ts; } }); } - getCompletionEntriesFromSymbols(symbols, activeCompletionSession); } else { - var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(previousToken); + var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); if (containingObjectLiteral) { isMemberCompletion = true; isNewIdentifierLocation = true; @@ -28707,65 +30542,54 @@ var ts; } var contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType); if (contextualTypeMembers && contextualTypeMembers.length > 0) { - var filteredMembers = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); - getCompletionEntriesFromSymbols(filteredMembers, activeCompletionSession); + symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(previousToken, 205)) { + else if (ts.getAncestor(contextToken, 207)) { isMemberCompletion = true; isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(previousToken)) { - var importDeclaration = ts.getAncestor(previousToken, 204); + if (showCompletionsInImportsClause(contextToken)) { + var importDeclaration = ts.getAncestor(contextToken, 206); ts.Debug.assert(importDeclaration !== undefined); var exports = typeInfoResolver.getExportsOfExternalModule(importDeclaration); - var filteredExports = filterModuleExports(exports, importDeclaration); - getCompletionEntriesFromSymbols(filteredExports, activeCompletionSession); + symbols = filterModuleExports(exports, importDeclaration); } } else { isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(previousToken); + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile); var symbolMeanings = 793056 | 107455 | 1536 | 8388608; - var _symbols = typeInfoResolver.getSymbolsInScope(node, symbolMeanings); - getCompletionEntriesFromSymbols(_symbols, activeCompletionSession); + symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings); } } - if (!isMemberCompletion) { - Array.prototype.push.apply(activeCompletionSession.entries, keywordCompletions); - } - log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart)); - return { - isMemberCompletion: isMemberCompletion, - isNewIdentifierLocation: isNewIdentifierLocation, - isBuilder: isNewIdentifierDefinitionLocation, - entries: activeCompletionSession.entries - }; - function getCompletionEntriesFromSymbols(symbols, session) { - var _start_1 = new Date().getTime(); - ts.forEach(symbols, function (symbol) { - var entry = createCompletionEntry(symbol, session.typeChecker, _location); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(session.symbols, id)) { - session.entries.push(entry); - session.symbols[id] = symbol; - } - } - }); - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - _start_1)); + log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location }; + function getScopeNode(initialToken, position, sourceFile) { + var scope = initialToken; + while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { + scope = scope.parent; + } + return scope; } function isCompletionListBlocker(previousToken) { - var _start_1 = new Date().getTime(); + var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || isIdentifierDefinitionLocation(previousToken) || isRightOfIllegalDot(previousToken); - log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - _start_1)); + log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } function showCompletionsInImportsClause(node) { if (node) { if (node.kind === 14 || node.kind === 23) { - return node.parent.kind === 207; + return node.parent.kind === 209; } } return false; @@ -28775,35 +30599,35 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 155 - || containingNodeKind === 133 - || containingNodeKind === 156 - || containingNodeKind === 151 - || containingNodeKind === 167; + return containingNodeKind === 157 + || containingNodeKind === 135 + || containingNodeKind === 158 + || containingNodeKind === 153 + || containingNodeKind === 169; case 16: - return containingNodeKind === 155 - || containingNodeKind === 133 - || containingNodeKind === 156 - || containingNodeKind === 159; + return containingNodeKind === 157 + || containingNodeKind === 135 + || containingNodeKind === 158 + || containingNodeKind === 161; case 18: - return containingNodeKind === 151; - case 116: + return containingNodeKind === 153; + case 117: return true; case 20: - return containingNodeKind === 200; + return containingNodeKind === 202; case 14: - return containingNodeKind === 196; - case 52: - return containingNodeKind === 193 - || containingNodeKind === 167; + return containingNodeKind === 198; + case 53: + return containingNodeKind === 195 + || containingNodeKind === 169; case 11: - return containingNodeKind === 169; + return containingNodeKind === 171; case 12: - return containingNodeKind === 173; - case 108: - case 106: + return containingNodeKind === 175; + case 109: case 107: - return containingNodeKind === 130; + case 108: + return containingNodeKind === 132; } switch (previousToken.getText()) { case "public": @@ -28818,9 +30642,9 @@ var ts; if (previousToken.kind === 8 || previousToken.kind === 9 || ts.isTemplateLiteralKind(previousToken.kind)) { - var _start_1 = previousToken.getStart(); + var start_2 = previousToken.getStart(); var end = previousToken.getEnd(); - if (_start_1 < position && position < end) { + if (start_2 < position && position < end) { return true; } else if (position === end) { @@ -28830,13 +30654,14 @@ var ts; return false; } function getContainingObjectLiteralApplicableForCompletion(previousToken) { + // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var _parent = previousToken.parent; + var parent_8 = previousToken.parent; switch (previousToken.kind) { case 14: case 23: - if (_parent && _parent.kind === 152) { - return _parent; + if (parent_8 && parent_8.kind === 154) { + return parent_8; } break; } @@ -28845,16 +30670,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 160: - case 161: - case 195: - case 132: - case 131: + case 162: + case 163: + case 197: case 134: - case 135: + case 133: case 136: case 137: case 138: + case 139: + case 140: return true; } return false; @@ -28864,58 +30689,58 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 193 || - containingNodeKind === 194 || - containingNodeKind === 175 || - containingNodeKind === 199 || - isFunction(containingNodeKind) || + return containingNodeKind === 195 || containingNodeKind === 196 || - containingNodeKind === 195 || + containingNodeKind === 177 || + containingNodeKind === 201 || + isFunction(containingNodeKind) || + containingNodeKind === 198 || containingNodeKind === 197 || - containingNodeKind === 149 || - containingNodeKind === 148; + containingNodeKind === 199 || + containingNodeKind === 151 || + containingNodeKind === 150; case 20: - return containingNodeKind === 149; + return containingNodeKind === 151; case 18: - return containingNodeKind === 149; + return containingNodeKind === 151; case 16: - return containingNodeKind === 217 || + return containingNodeKind === 220 || isFunction(containingNodeKind); case 14: - return containingNodeKind === 199 || - containingNodeKind === 197 || - containingNodeKind === 143 || - containingNodeKind === 148; + return containingNodeKind === 201 || + containingNodeKind === 199 || + containingNodeKind === 145 || + containingNodeKind === 150; case 22: - return containingNodeKind === 129 && - (previousToken.parent.parent.kind === 197 || - previousToken.parent.parent.kind === 143); + return containingNodeKind === 131 && + (previousToken.parent.parent.kind === 199 || + previousToken.parent.parent.kind === 145); case 24: - return containingNodeKind === 196 || - containingNodeKind === 195 || + return containingNodeKind === 198 || containingNodeKind === 197 || + containingNodeKind === 199 || isFunction(containingNodeKind); - case 109: - return containingNodeKind === 130; - case 21: - return containingNodeKind === 128 || - containingNodeKind === 133 || - (previousToken.parent.parent.kind === 149); - case 108: - case 106: - case 107: - return containingNodeKind === 128; - case 68: - case 76: - case 103: - case 82: - case 97: - case 115: - case 119: - case 84: - case 104: - case 69: case 110: + return containingNodeKind === 132; + case 21: + return containingNodeKind === 129 || + containingNodeKind === 135 || + (previousToken.parent.parent.kind === 151); + case 109: + case 107: + case 108: + return containingNodeKind === 129; + case 69: + case 77: + case 104: + case 83: + case 98: + case 116: + case 120: + case 85: + case 105: + case 70: + case 111: return true; } switch (previousToken.getText()) { @@ -28946,10 +30771,10 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 207) { + importDeclaration.importClause.namedBindings.kind === 209) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { - var _name = el.propertyName || el.name; - exisingImports[_name.text] = true; + var name = el.propertyName || el.name; + exisingImports[name.text] = true; }); } if (ts.isEmpty(exisingImports)) { @@ -28963,7 +30788,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 218 && m.kind !== 219) { + if (m.kind !== 221 && m.kind !== 222) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -28971,44 +30796,78 @@ var ts; } existingMemberNames[m.name.text] = true; }); - var _filteredMembers = []; + var filteredMembers = []; ts.forEach(contextualMemberSymbols, function (s) { if (!existingMemberNames[s.name]) { - _filteredMembers.push(s); + filteredMembers.push(s); } }); - return _filteredMembers; + return filteredMembers; + } + } + function getCompletionsAtPosition(fileName, position) { + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location; + if (!symbols || symbols.length === 0) { + return undefined; + } + var entries = getCompletionEntriesFromSymbols(symbols); + if (!isMemberCompletion) { + ts.addRange(entries, keywordCompletions); + } + return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + function getCompletionEntriesFromSymbols(symbols) { + var start = new Date().getTime(); + var entries = []; + var nameToSymbol = {}; + for (var _i = 0, _n = symbols.length; _i < _n; _i++) { + var symbol = symbols[_i]; + var entry = createCompletionEntry(symbol, typeInfoResolver, location); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!ts.lookUp(nameToSymbol, id)) { + entries.push(entry); + nameToSymbol[id] = symbol; + } + } + } + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); + return entries; } } function getCompletionEntryDetails(fileName, position, entryName) { - var sourceFile = getValidSourceFile(fileName); - var session = activeCompletionSession; - if (!session || session.fileName !== fileName || session.position !== position) { - return undefined; + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (completionData) { + var symbols = completionData.symbols, location_2 = completionData.location; + var target = program.getCompilerOptions().target; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayName(s, target, false) === entryName ? s : undefined; }); + if (symbol) { + var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, typeInfoResolver, location_2, 7); + return { + name: entryName, + kind: displayPartsDocumentationsAndSymbolKind.symbolKind, + kindModifiers: getSymbolModifiers(symbol), + displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, + documentation: displayPartsDocumentationsAndSymbolKind.documentation + }; + } } - var symbol = ts.lookUp(activeCompletionSession.symbols, ts.escapeIdentifier(entryName)); - if (symbol) { - var _location = ts.getTouchingPropertyName(sourceFile, position); - var completionEntry = createCompletionEntry(symbol, session.typeChecker, _location); - ts.Debug.assert(session.typeChecker.getTypeOfSymbolAtLocation(symbol, _location) !== undefined, "Could not find type for symbol"); - var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), _location, session.typeChecker, _location, 7); - return { - name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, - kindModifiers: completionEntry.kindModifiers, - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation - }; - } - else { + var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); + if (keywordCompletion) { return { name: entryName, kind: ScriptElementKind.keyword, kindModifiers: ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, 5)], + displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], documentation: undefined }; } + return undefined; } function getSymbolKind(symbol, typeResolver, location) { var flags = symbol.getFlags(); @@ -29122,14 +30981,14 @@ var ts; var signature; type = typeResolver.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 153) { + if (location.parent && location.parent.kind === 155) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 155 || location.kind === 156) { + if (location.kind === 157 || location.kind === 158) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -29141,7 +31000,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 156 || callExpression.expression.kind === 90; + var useConstructSignatures = callExpression.kind === 158 || callExpression.expression.kind === 91; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -29153,12 +31012,10 @@ var ts; } else if (symbolFlags & 8388608) { symbolKind = ScriptElementKind.alias; - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart(symbolKind)); - displayParts.push(ts.punctuationPart(17)); + pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -29176,7 +31033,7 @@ var ts; displayParts.push(ts.punctuationPart(51)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } if (!(type.flags & 32768)) { @@ -29191,64 +31048,64 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 113 && location.parent.kind === 133)) { + (location.kind === 114 && location.parent.kind === 135)) { var functionDeclaration = location.parent; - var _allSignatures = functionDeclaration.kind === 133 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 135 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeResolver.isImplementationOfOverload(functionDeclaration)) { signature = typeResolver.getSignatureFromDeclaration(functionDeclaration); } else { - signature = _allSignatures[0]; + signature = allSignatures[0]; } - if (functionDeclaration.kind === 133) { + if (functionDeclaration.kind === 135) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 136 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 138 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } - addSignatureDisplayParts(signature, _allSignatures); + addSignatureDisplayParts(signature, allSignatures); hasAddedSymbolInfo = true; } } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - displayParts.push(ts.keywordPart(68)); + displayParts.push(ts.keywordPart(69)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(103)); + displayParts.push(ts.keywordPart(104)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(122)); + displayParts.push(ts.keywordPart(123)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(69)); + displayParts.push(ts.keywordPart(70)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(76)); + displayParts.push(ts.keywordPart(77)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(116)); + displayParts.push(ts.keywordPart(117)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -29260,60 +31117,60 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(85)); + displayParts.push(ts.keywordPart(86)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 127).parent; - var _signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 137) { - displayParts.push(ts.keywordPart(87)); + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128).parent; + var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 139) { + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 136 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 138 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, _signature, sourceFile, 32)); + displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, sourceFile, 32)); } } if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 220) { + if (declaration.kind === 223) { var constantValue = typeResolver.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), 7)); + displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } } } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(84)); + displayParts.push(ts.keywordPart(85)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 203) { + if (declaration.kind === 205) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(117)); + displayParts.push(ts.keywordPart(118)); displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), 8)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17)); } else { var internalAliasSymbol = typeResolver.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(52)); + displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -29347,8 +31204,8 @@ var ts; symbolFlags & 131072 || symbolFlags & 98304 || symbolKind === ScriptElementKind.memberFunctionElement) { - var _allSignatures_1 = type.getCallSignatures(); - addSignatureDisplayParts(_allSignatures_1[0], _allSignatures_1); + var allSignatures = type.getCallSignatures(); + addSignatureDisplayParts(allSignatures[0], allSignatures); } } } @@ -29372,20 +31229,34 @@ var ts; function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); if (symbolKind) { - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart(symbolKind)); - displayParts.push(ts.punctuationPart(17)); + pushTypePart(symbolKind); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } } + function pushTypePart(symbolKind) { + switch (symbolKind) { + case ScriptElementKind.variableElement: + case ScriptElementKind.functionElement: + case ScriptElementKind.letElement: + case ScriptElementKind.constElement: + case ScriptElementKind.constructorImplementationElement: + displayParts.push(ts.textOrKeywordPart(symbolKind)); + return; + default: + displayParts.push(ts.punctuationPart(16)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(17)); + return; + } + } function addSignatureDisplayParts(signature, allSignatures, flags) { displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(16)); displayParts.push(ts.operatorPart(33)); - displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), 7)); + displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); displayParts.push(ts.punctuationPart(17)); @@ -29393,10 +31264,10 @@ var ts; documentation = signature.getDocumentationComment(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var _typeParameterParts = ts.mapToDisplayParts(function (writer) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, _typeParameterParts); + displayParts.push.apply(displayParts, typeParameterParts); } } function getQuickInfoAtPosition(fileName, position) { @@ -29409,11 +31280,11 @@ var ts; var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 64: - case 153: - case 125: - case 92: - case 90: + case 65: + case 155: + case 126: + case 93: + case 91: var type = typeInfoResolver.getTypeAtLocation(node); if (type) { return { @@ -29436,6 +31307,16 @@ var ts; documentation: displayPartsDocumentationsAndKind.documentation }; } + function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + kind: symbolKind, + name: symbolName, + containerKind: undefined, + containerName: containerName + }; + } function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -29446,7 +31327,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [getDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; } var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); if (comment) { @@ -29469,22 +31350,22 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 64 && node.parent === declaration) { + if (node.kind === 65 && node.parent === declaration) { symbol = typeInfoResolver.getAliasedSymbol(symbol); } } - var result = []; - if (node.parent.kind === 219) { + if (node.parent.kind === 222) { var shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); + if (!shorthandSymbol) { + return []; + } var shorthandDeclarations = shorthandSymbol.getDeclarations(); var shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node); var shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol); var shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node); - ts.forEach(shorthandDeclarations, function (declaration) { - result.push(getDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName)); - }); - return result; + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); } + var result = []; var declarations = symbol.getDeclarations(); var symbolName = typeInfoResolver.symbolToString(symbol); var symbolKind = getSymbolKind(symbol, typeInfoResolver, node); @@ -29493,46 +31374,15 @@ var ts; if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { ts.forEach(declarations, function (declaration) { - result.push(getDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); } return result; - function getDefinitionInfo(node, symbolKind, symbolName, containerName) { - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - kind: symbolKind, - name: symbolName, - containerKind: undefined, - containerName: containerName - }; - } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var _declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 133) || - (!selectConstructors && (d.kind === 195 || d.kind === 132 || d.kind === 131))) { - _declarations.push(d); - if (d.body) - definition = d; - } - }); - if (definition) { - result.push(getDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (_declarations.length) { - result.push(getDefinitionInfo(_declarations[_declarations.length - 1], symbolKind, symbolName, containerName)); - return true; - } - return false; - } function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 113) { + if (isNewExpressionTarget(location) || location.kind === 114) { if (symbol.flags & 32) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 196); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 198); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -29544,6 +31394,27 @@ var ts; } return false; } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 135) || + (!selectConstructors && (d.kind === 197 || d.kind === 134 || d.kind === 133))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName)); + return true; + } + return false; + } } function getOccurrencesAtPosition(fileName, position) { synchronizeHostData(); @@ -29552,108 +31423,108 @@ var ts; if (!node) { return undefined; } - if (node.kind === 64 || node.kind === 92 || node.kind === 90 || + if (node.kind === 65 || node.kind === 93 || node.kind === 91 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - return getReferencesForNode(node, [sourceFile], true, false, false); + return convertReferences(getReferencesForNode(node, [sourceFile], true, false, false)); } switch (node.kind) { - case 83: - case 75: - if (hasKind(node.parent, 178)) { + case 84: + case 76: + if (hasKind(node.parent, 180)) { return getIfElseOccurrences(node.parent); } break; - case 89: - if (hasKind(node.parent, 186)) { + case 90: + if (hasKind(node.parent, 188)) { return getReturnOccurrences(node.parent); } break; - case 93: - if (hasKind(node.parent, 190)) { + case 94: + if (hasKind(node.parent, 192)) { return getThrowOccurrences(node.parent); } break; - case 67: - if (hasKind(parent(parent(node)), 191)) { + case 68: + if (hasKind(parent(parent(node)), 193)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 95: - case 80: - if (hasKind(parent(node), 191)) { + case 96: + case 81: + if (hasKind(parent(node), 193)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 91: - if (hasKind(node.parent, 188)) { + case 92: + if (hasKind(node.parent, 190)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 66: - case 72: - if (hasKind(parent(parent(parent(node))), 188)) { + case 67: + case 73: + if (hasKind(parent(parent(parent(node))), 190)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 65: - case 70: - if (hasKind(node.parent, 185) || hasKind(node.parent, 184)) { + case 66: + case 71: + if (hasKind(node.parent, 187) || hasKind(node.parent, 186)) { return getBreakOrContinueStatementOccurences(node.parent); } break; - case 81: - if (hasKind(node.parent, 181) || - hasKind(node.parent, 182) || - hasKind(node.parent, 183)) { + case 82: + if (hasKind(node.parent, 183) || + hasKind(node.parent, 184) || + hasKind(node.parent, 185)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 99: - case 74: - if (hasKind(node.parent, 180) || hasKind(node.parent, 179)) { + case 100: + case 75: + if (hasKind(node.parent, 182) || hasKind(node.parent, 181)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 113: - if (hasKind(node.parent, 133)) { + case 114: + if (hasKind(node.parent, 135)) { return getConstructorOccurrences(node.parent); } break; - case 115: - case 119: - if (hasKind(node.parent, 134) || hasKind(node.parent, 135)) { + case 116: + case 120: + if (hasKind(node.parent, 136) || hasKind(node.parent, 137)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 175)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 177)) { return getModifierOccurrences(node.kind, node.parent); } } return undefined; function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 178) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 180) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 83); - for (var _i = children.length - 1; _i >= 0; _i--) { - if (pushKeywordIf(keywords, children[_i], 75)) { + pushKeywordIf(keywords, children[0], 84); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 76)) { break; } } - if (!hasKind(ifStatement.elseStatement, 178)) { + if (!hasKind(ifStatement.elseStatement, 180)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; - for (var _i_1 = 0; _i_1 < keywords.length; _i_1++) { - if (keywords[_i_1].kind === 75 && _i_1 < keywords.length - 1) { - var elseKeyword = keywords[_i_1]; - var ifKeyword = keywords[_i_1 + 1]; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 76 && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; var shouldHighlightNextKeyword = true; for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { @@ -29667,25 +31538,25 @@ var ts; textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), isWriteAccess: false }); - _i_1++; + i++; continue; } } - result.push(getReferenceEntryFromNode(keywords[_i_1])); + result.push(getReferenceEntryFromNode(keywords[i])); } return result; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 174))) { + if (!(func && hasKind(func.body, 176))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 89); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 90); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 93); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 94); }); return ts.map(keywords, getReferenceEntryFromNode); } @@ -29696,11 +31567,11 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 93); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 94); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 89); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 90); }); } return ts.map(keywords, getReferenceEntryFromNode); @@ -29710,10 +31581,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 190) { + if (node.kind === 192) { statementAccumulator.push(node); } - else if (node.kind === 191) { + else if (node.kind === 193) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -29734,39 +31605,39 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var _parent = child.parent; - if (ts.isFunctionBlock(_parent) || _parent.kind === 221) { - return _parent; + var parent_9 = child.parent; + if (ts.isFunctionBlock(parent_9) || parent_9.kind === 224) { + return parent_9; } - if (_parent.kind === 191) { - var tryStatement = _parent; + if (parent_9.kind === 193) { + var tryStatement = parent_9; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = _parent; + child = parent_9; } return undefined; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 95); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 96); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 67); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 68); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 80, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 80); + var finallyKeyword = ts.findChildOfKind(tryStatement, 81, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 81); } return ts.map(keywords, getReferenceEntryFromNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 81, 99, 74)) { - if (loopNode.kind === 179) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82, 100, 75)) { + if (loopNode.kind === 181) { var loopTokens = loopNode.getChildren(); - for (var _i = loopTokens.length - 1; _i >= 0; _i--) { - if (pushKeywordIf(keywords, loopTokens[_i], 99)) { + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 100)) { break; } } @@ -29775,20 +31646,20 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 65, 70); + pushKeywordIf(keywords, statement.getFirstToken(), 66, 71); } }); return ts.map(keywords, getReferenceEntryFromNode); } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 91); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 92); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 66, 72); + pushKeywordIf(keywords, clause.getFirstToken(), 67, 73); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 65); + pushKeywordIf(keywords, statement.getFirstToken(), 66); } }); }); @@ -29798,13 +31669,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { + case 183: + case 184: + case 185: case 181: case 182: - case 183: - case 179: - case 180: return getLoopBreakContinueOccurrences(owner); - case 188: + case 190: return getSwitchCaseDefaultOccurrences(owner); } } @@ -29815,7 +31686,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 185 || node.kind === 184) { + if (node.kind === 187 || node.kind === 186) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -29829,23 +31700,23 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var _node = statement.parent; _node; _node = _node.parent) { - switch (_node.kind) { - case 188: - if (statement.kind === 184) { + for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { + switch (node_1.kind) { + case 190: + if (statement.kind === 186) { continue; } - case 181: - case 182: case 183: - case 180: - case 179: - if (!statement.label || isLabeledBy(_node, statement.label.text)) { - return _node; + case 184: + case 185: + case 182: + case 181: + if (!statement.label || isLabeledBy(node_1, statement.label.text)) { + return node_1; } break; default: - if (ts.isFunctionLike(_node)) { + if (ts.isFunctionLike(node_1)) { return undefined; } break; @@ -29858,38 +31729,38 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 113); + return pushKeywordIf(keywords, token, 114); }); }); return ts.map(keywords, getReferenceEntryFromNode); } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 134); - tryPushAccessorKeyword(accessorDeclaration.symbol, 135); + tryPushAccessorKeyword(accessorDeclaration.symbol, 136); + tryPushAccessorKeyword(accessorDeclaration.symbol, 137); return ts.map(keywords, getReferenceEntryFromNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 115, 119); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 120); }); } } } function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; - if (declaration.flags & 112) { - if (!(container.kind === 196 || - (declaration.kind === 128 && hasKind(container, 133)))) { + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 198 || + (declaration.kind === 129 && hasKind(container, 135)))) { return undefined; } } - else if (declaration.flags & 128) { - if (container.kind !== 196) { + else if (modifier === 110) { + if (container.kind !== 198) { return undefined; } } - else if (declaration.flags & (1 | 2)) { - if (!(container.kind === 201 || container.kind === 221)) { + else if (modifier === 78 || modifier === 115) { + if (!(container.kind === 203 || container.kind === 224)) { return undefined; } } @@ -29900,18 +31771,18 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 201: - case 221: + case 203: + case 224: nodes = container.statements; break; - case 133: + case 135: nodes = container.parameters.concat(container.parent.members); break; - case 196: + case 198: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 133 && member; + return member.kind === 135 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -29929,17 +31800,17 @@ var ts; return ts.map(keywords, getReferenceEntryFromNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 108: - return 16; - case 106: - return 32; - case 107: - return 64; case 109: + return 16; + case 107: + return 32; + case 108: + return 64; + case 110: return 128; - case 77: + case 78: return 1; - case 114: + case 115: return 2; default: ts.Debug.fail(); @@ -29964,46 +31835,63 @@ var ts; return false; } } + function convertReferences(referenceSymbols) { + if (!referenceSymbols) { + return undefined; + } + var referenceEntries = []; + for (var _i = 0, _n = referenceSymbols.length; _i < _n; _i++) { + var referenceSymbol = referenceSymbols[_i]; + ts.addRange(referenceEntries, referenceSymbol.references); + } + return referenceEntries; + } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return findReferences(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - return findReferences(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return convertReferences(referencedSymbols); } - function findReferences(fileName, position, findInStrings, findInComments) { + function findReferences(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); + } + function findReferencedSymbols(fileName, position, findInStrings, findInComments) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, position); if (!node) { return undefined; } - if (node.kind !== 64 && + if (node.kind !== 65 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 64 || node.kind === 7 || node.kind === 8); + ts.Debug.assert(node.kind === 65 || node.kind === 7 || node.kind === 8); return getReferencesForNode(node, program.getSourceFiles(), false, findInStrings, findInComments); } function getReferencesForNode(node, sourceFiles, searchOnlyInCurrentFile, findInStrings, findInComments) { if (isLabelName(node)) { if (isJumpStatementTarget(node)) { var labelDefinition = getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : [getReferenceEntryFromNode(node)]; + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; } else { return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 92) { + if (node.kind === 93) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 90) { + if (node.kind === 91) { return getReferencesForSuperKeyword(node); } var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { - return [getReferenceEntryFromNode(node)]; + return undefined; } var declarations = symbol.declarations; if (!declarations || !declarations.length) { @@ -30013,15 +31901,16 @@ var ts; var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); var declaredName = getDeclaredName(symbol, node); var scope = getSymbolScope(symbol); + var symbolToIndex = []; if (scope) { result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { if (searchOnlyInCurrentFile) { ts.Debug.assert(sourceFiles.length === 1); result = []; - getReferencesInNode(sourceFiles[0], symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(sourceFiles[0], symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { var internedName = getInternedName(symbol, node, declarations); @@ -30030,48 +31919,64 @@ var ts; var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } }); } } return result; + function getDefinition(symbol) { + var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), typeInfoResolver, node); + var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + return { + containerKind: "", + containerName: "", + name: name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0) + }; + } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 208 || location.parent.kind === 212) && + (location.parent.kind === 210 || location.parent.kind === 214) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 208 || declaration.kind === 212; + return declaration.kind === 210 || declaration.kind === 214; }); } function getDeclaredName(symbol, location) { - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 160 ? d : undefined; }); - var _name; + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 162 ? d : undefined; }); + var name; if (functionExpression && functionExpression.name) { - _name = functionExpression.name.text; + name = functionExpression.name.text; } if (isImportOrExportSpecifierName(location)) { return location.getText(); } - _name = typeInfoResolver.symbolToString(symbol); - return stripQuotes(_name); + name = typeInfoResolver.symbolToString(symbol); + return stripQuotes(name); } function getInternedName(symbol, location, declarations) { if (isImportOrExportSpecifierName(location)) { return location.getText(); } - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 160 ? d : undefined; }); - var _name = functionExpression && functionExpression.name + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 162 ? d : undefined; }); + var name = functionExpression && functionExpression.name ? functionExpression.name.text : symbol.name; - return stripQuotes(_name); + return stripQuotes(name); } function stripQuotes(name) { - var _length = name.length; - if (_length >= 2 && name.charCodeAt(0) === 34 && name.charCodeAt(_length - 1) === 34) { - return name.substring(1, _length - 1); + var length = name.length; + if (length >= 2 && name.charCodeAt(0) === 34 && name.charCodeAt(length - 1) === 34) { + return name.substring(1, length - 1); } ; return name; @@ -30080,7 +31985,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 196); + return ts.getAncestor(privateDeclaration, 198); } } if (symbol.flags & 8388608) { @@ -30089,25 +31994,25 @@ var ts; if (symbol.parent || (symbol.flags & 268435456)) { return undefined; } - var _scope = undefined; - var _declarations = symbol.getDeclarations(); - if (_declarations) { - for (var _i = 0, _n = _declarations.length; _i < _n; _i++) { - var declaration = _declarations[_i]; + var scope = undefined; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, _n = declarations.length; _i < _n; _i++) { + var declaration = declarations[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; } - if (_scope && _scope !== container) { + if (scope && scope !== container) { return undefined; } - if (container.kind === 221 && !ts.isExternalModule(container)) { + if (container.kind === 224 && !ts.isExternalModule(container)) { return undefined; } - _scope = container; + scope = container; } } - return _scope; + return scope; } function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { var positions = []; @@ -30132,27 +32037,35 @@ var ts; return positions; } function getLabelReferencesInNode(container, targetLabel) { - var _result = []; + var references = []; var sourceFile = container.getSourceFile(); var labelName = targetLabel.text; var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.getWidth() !== labelName.length) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { return; } - if (_node === targetLabel || - (isJumpStatementTarget(_node) && getTargetLabel(_node, labelName) === targetLabel)) { - _result.push(getReferenceEntryFromNode(_node)); + if (node === targetLabel || + (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); } }); - return _result; + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) + }; + return [{ definition: definition, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 64: + case 65: return node.getWidth() === searchSymbolName.length; case 8: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -30169,7 +32082,7 @@ var ts; } return false; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result) { + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { var sourceFile = container.getSourceFile(); var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { - result.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); + var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } } }); } + return; + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol), + references: [] + }); + } + return result[index]; + } function isInString(position) { var token = ts.getTokenAtPosition(sourceFile, position); return token && token.kind === 8 && position > token.getStart(); @@ -30232,105 +32165,116 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 130: - case 129: case 132: case 131: - case 133: case 134: + case 133: case 135: + case 136: + case 137: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; default: return undefined; } - var _result = []; + var references = []; var sourceFile = searchSpaceNode.getSourceFile(); var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.kind !== 90) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 91) { return; } - var container = ts.getSuperContainer(_node, false); + var container = ts.getSuperContainer(node, false); if (container && (128 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - _result.push(getReferenceEntryFromNode(_node)); + references.push(getReferenceEntryFromNode(node)); } }); - return _result; + var definition = getDefinition(searchSpaceNode.symbol); + return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { - case 132: - case 131: + case 134: + case 133: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } - case 130: - case 129: - case 133: - case 134: + case 132: + case 131: case 135: + case 136: + case 137: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 221: + case 224: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 195: - case 160: + case 197: + case 162: break; default: return undefined; } - var _result = []; + var references = []; var possiblePositions; - if (searchSpaceNode.kind === 221) { + if (searchSpaceNode.kind === 224) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, _result); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); }); } else { var sourceFile = searchSpaceNode.getSourceFile(); possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, _result); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); } - return _result; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) + }, + references: references + }]; function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var _node = ts.getTouchingWord(sourceFile, position); - if (!_node || _node.kind !== 92) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 93) { return; } - var container = ts.getThisContainer(_node, false); + var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 160: - case 195: + case 162: + case 197: if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 132: - case 131: + case 134: + case 133: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 196: + case 198: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { - result.push(getReferenceEntryFromNode(_node)); + result.push(getReferenceEntryFromNode(node)); } break; - case 221: - if (container.kind === 221 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(_node)); + case 224: + if (container.kind === 224 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); } break; } @@ -30338,37 +32282,37 @@ var ts; } } function populateSearchSymbolSet(symbol, location) { - var _result = [symbol]; + var result = [symbol]; if (isImportOrExportSpecifierImportSymbol(symbol)) { - _result.push(typeInfoResolver.getAliasedSymbol(symbol)); + result.push(typeInfoResolver.getAliasedSymbol(symbol)); } if (isNameOfPropertyAssignment(location)) { ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - _result.push.apply(_result, typeInfoResolver.getRootSymbols(contextualSymbol)); + result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol)); }); var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(location.parent); if (shorthandValueSymbol) { - _result.push(shorthandValueSymbol); + result.push(shorthandValueSymbol); } } ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) { if (rootSymbol !== symbol) { - _result.push(rootSymbol); + result.push(rootSymbol); } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), _result); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); } }); - return _result; + return result; } function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 196) { + if (declaration.kind === 198) { getPropertySymbolFromTypeReference(ts.getClassBaseTypeNode(declaration)); ts.forEach(ts.getClassImplementedTypeNodes(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 197) { + else if (declaration.kind === 199) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -30387,57 +32331,59 @@ var ts; } } } - function isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation) { + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { if (searchSymbols.indexOf(referenceSymbol) >= 0) { - return true; + return referenceSymbol; } - if (isImportOrExportSpecifierImportSymbol(referenceSymbol) && - searchSymbols.indexOf(typeInfoResolver.getAliasedSymbol(referenceSymbol)) >= 0) { - return true; + if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + var aliasedSymbol = typeInfoResolver.getAliasedSymbol(referenceSymbol); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } } if (isNameOfPropertyAssignment(referenceLocation)) { return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { - return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0; }); + return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); }); } return ts.forEach(typeInfoResolver.getRootSymbols(referenceSymbol), function (rootSymbol) { if (searchSymbols.indexOf(rootSymbol) >= 0) { - return true; + return rootSymbol; } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - var _result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), _result); - return ts.forEach(_result, function (s) { return searchSymbols.indexOf(s) >= 0; }); + var result_2 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_2); + return ts.forEach(result_2, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } - return false; + return undefined; }); } function getPropertySymbolsFromContextualType(node) { if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeInfoResolver.getContextualType(objectLiteral); - var _name = node.text; + var name_20 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(_name); + var unionProperty = contextualType.getProperty(name_20); if (unionProperty) { return [unionProperty]; } else { - var _result = []; + var result_3 = []; ts.forEach(contextualType.types, function (t) { - var _symbol = t.getProperty(_name); - if (_symbol) { - _result.push(_symbol); + var symbol = t.getProperty(name_20); + if (symbol) { + result_3.push(symbol); } }); - return _result; + return result_3; } } else { - var _symbol = contextualType.getProperty(_name); - if (_symbol) { - return [_symbol]; + var symbol_1 = contextualType.getProperty(name_20); + if (symbol_1) { + return [symbol_1]; } } } @@ -30475,17 +32421,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 64 && ts.isDeclarationName(node)) { + if (node.kind === 65 && ts.isDeclarationName(node)) { return true; } - var _parent = node.parent; - if (_parent) { - if (_parent.kind === 166 || _parent.kind === 165) { + var parent = node.parent; + if (parent) { + if (parent.kind === 168 || parent.kind === 167) { return true; } - else if (_parent.kind === 167 && _parent.left === node) { - var operator = _parent.operatorToken.kind; - return 52 <= operator && operator <= 63; + else if (parent.kind === 169 && parent.left === node) { + var operator = parent.operatorToken.kind; + return 53 <= operator && operator <= 64; } } return false; @@ -30495,7 +32441,7 @@ var ts; return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); } function containErrors(diagnostics) { - return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === 1; }); + return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); } function getEmitOutput(fileName) { synchronizeHostData(); @@ -30516,33 +32462,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 128: - case 193: - case 150: - case 130: case 129: - case 218: - case 219: - case 220: + case 195: + case 152: case 132: case 131: - case 133: + case 221: + case 222: + case 223: case 134: + case 133: case 135: - case 195: - case 160: - case 161: - case 217: - return 1; - case 127: + case 136: + case 137: case 197: - case 198: - case 143: - return 2; - case 196: + case 162: + case 163: + case 220: + return 1; + case 128: case 199: - return 1 | 2; case 200: + case 145: + return 2; + case 198: + case 201: + return 1 | 2; + case 202: if (node.name.kind === 8) { return 4 | 1; } @@ -30552,14 +32498,14 @@ var ts; else { return 4; } - case 207: - case 208: - case 203: - case 204: case 209: case 210: + case 205: + case 206: + case 211: + case 212: return 1 | 2 | 4; - case 221: + case 224: return 4 | 1; } return 1 | 2 | 4; @@ -30569,35 +32515,35 @@ var ts; if (isRightSideOfQualifiedName(node)) { node = node.parent; } - return node.parent.kind === 139; + return node.parent.kind === 141; } function isNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 125) { - while (root.parent && root.parent.kind === 125) + if (root.parent.kind === 126) { + while (root.parent && root.parent.kind === 126) root = root.parent; isLastClause = root.right === node; } - return root.parent.kind === 139 && !isLastClause; + return root.parent.kind === 141 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 125) { + while (node.parent.kind === 126) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 64); - if (node.parent.kind === 125 && + ts.Debug.assert(node.kind === 65); + if (node.parent.kind === 126 && node.parent.right === node && - node.parent.parent.kind === 203) { + node.parent.parent.kind === 205) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 211) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -30631,15 +32577,15 @@ var ts; return; } switch (node.kind) { - case 153: - case 125: + case 155: + case 126: case 8: - case 79: - case 94: - case 88: - case 90: - case 92: - case 64: + case 80: + case 95: + case 89: + case 91: + case 93: + case 65: break; default: return; @@ -30650,7 +32596,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 200 && + if (nodeForStartPos.parent.parent.kind === 202 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -30706,13 +32652,13 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 200 && ts.getModuleInstanceState(declaration) == 1; + return declaration.kind === 202 && ts.getModuleInstanceState(declaration) == 1; }); } } function processNode(node) { if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 64 && node.getWidth() > 0) { + if (node.kind === 65 && node.getWidth() > 0) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); @@ -30823,17 +32769,17 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 52) { - if (token.parent.kind === 193 || - token.parent.kind === 130 || - token.parent.kind === 128) { + if (tokenKind === 53) { + if (token.parent.kind === 195 || + token.parent.kind === 132 || + token.parent.kind === 129) { return ClassificationTypeNames.operator; } } - if (token.parent.kind === 167 || - token.parent.kind === 165 || - token.parent.kind === 166 || - token.parent.kind === 168) { + if (token.parent.kind === 169 || + token.parent.kind === 167 || + token.parent.kind === 168 || + token.parent.kind === 170) { return ClassificationTypeNames.operator; } } @@ -30851,30 +32797,30 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return ClassificationTypeNames.stringLiteral; } - else if (tokenKind === 64) { + else if (tokenKind === 65) { if (token) { switch (token.parent.kind) { - case 196: + case 198: if (token.parent.name === token) { return ClassificationTypeNames.className; } return; - case 127: + case 128: if (token.parent.name === token) { return ClassificationTypeNames.typeParameterName; } return; - case 197: + case 199: if (token.parent.name === token) { return ClassificationTypeNames.interfaceName; } return; - case 199: + case 201: if (token.parent.name === token) { return ClassificationTypeNames.enumName; } return; - case 200: + case 202: if (token.parent.name === token) { return ClassificationTypeNames.moduleName; } @@ -30993,9 +32939,9 @@ var ts; continue; } var descriptor = undefined; - for (var _i = 0, n = descriptors.length; _i < n; _i++) { - if (matchArray[_i + firstDescriptorCaptureIndex]) { - descriptor = descriptors[_i]; + for (var i = 0, n = descriptors.length; i < n; i++) { + if (matchArray[i + firstDescriptorCaptureIndex]) { + descriptor = descriptors[i]; } } ts.Debug.assert(descriptor !== undefined); @@ -31015,15 +32961,17 @@ var ts; return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); } function getTodoCommentsRegExp() { + // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to + // filter them out later in the final result array. var singleLineCommentStart = /(?:\/\/+\s*)/.source; var multiLineCommentStart = /(?:\/\*+\s*)/.source; var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; - var _preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; var messagePortion = "(" + literals + messageRemainder + ")"; - var regExpString = _preamble + messagePortion + endOfLineOrEndOfComment; + var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { @@ -31036,7 +32984,7 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 64) { + if (node && node.kind === 65) { var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -31045,8 +32993,8 @@ var ts; if (defaultLibFileName) { for (var _i = 0, _n = declarations.length; _i < _n; _i++) { var current = declarations[_i]; - var _sourceFile = current.getSourceFile(); - if (_sourceFile && getCanonicalFileName(ts.normalizePath(_sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { + var sourceFile_1 = current.getSourceFile(); + if (sourceFile_1 && getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } } @@ -31093,6 +33041,7 @@ var ts; getQuickInfoAtPosition: getQuickInfoAtPosition, getDefinitionAtPosition: getDefinitionAtPosition, getReferencesAtPosition: getReferencesAtPosition, + findReferences: findReferences, getOccurrencesAtPosition: getOccurrencesAtPosition, getNameOrDottedNameSpan: getNameOrDottedNameSpan, getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, @@ -31126,13 +33075,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 64: + case 65: nameTable[node.text] = node.text; break; case 8: case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 213 || + node.parent.kind === 216 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -31145,40 +33094,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 154 && + node.parent.kind === 156 && node.parent.argumentExpression === node; } function createClassifier() { - var _scanner = ts.createScanner(2, false); + var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[64] = true; + noRegexTable[65] = true; noRegexTable[8] = true; noRegexTable[7] = true; noRegexTable[9] = true; - noRegexTable[92] = true; + noRegexTable[93] = true; noRegexTable[38] = true; noRegexTable[39] = true; noRegexTable[17] = true; noRegexTable[19] = true; noRegexTable[15] = true; - noRegexTable[94] = true; - noRegexTable[79] = true; + noRegexTable[95] = true; + noRegexTable[80] = true; var templateStack = []; - function isAccessibilityModifier(kind) { - switch (kind) { - case 108: - case 106: - case 107: - return true; - } - return false; - } function canFollow(keyword1, keyword2) { - if (isAccessibilityModifier(keyword1)) { - if (keyword2 === 115 || - keyword2 === 119 || - keyword2 === 113 || - keyword2 === 109) { + if (ts.isAccessibilityModifier(keyword1)) { + if (keyword2 === 116 || + keyword2 === 120 || + keyword2 === 114 || + keyword2 === 110) { return true; } return false; @@ -31216,40 +33156,40 @@ var ts; templateStack.push(11); break; } - _scanner.setText(text); + scanner.setText(text); var result = { finalLexState: 0, entries: [] }; var angleBracketStack = 0; do { - token = _scanner.scan(); + token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 36 || token === 56) && !noRegexTable[lastNonTriviaToken]) { - if (_scanner.reScanSlashToken() === 9) { + if ((token === 36 || token === 57) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 9) { token = 9; } } else if (lastNonTriviaToken === 20 && isKeyword(token)) { - token = 64; + token = 65; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 64; + token = 65; } - else if (lastNonTriviaToken === 64 && + else if (lastNonTriviaToken === 65 && token === 24) { angleBracketStack++; } else if (token === 25 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 111 || - token === 120 || - token === 118 || - token === 112 || - token === 121) { + else if (token === 112 || + token === 121 || + token === 119 || + token === 113 || + token === 122) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 64; + token = 65; } } else if (token === 11) { @@ -31264,7 +33204,7 @@ var ts; if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); if (lastTemplateStackToken === 11) { - token = _scanner.reScanTemplateToken(); + token = scanner.reScanTemplateToken(); if (token === 13) { templateStack.pop(); } @@ -31284,13 +33224,13 @@ var ts; } while (token !== 1); return result; function processToken() { - var start = _scanner.getTokenPos(); - var end = _scanner.getTextPos(); + var start = scanner.getTokenPos(); + var end = scanner.getTextPos(); addResult(end - start, classFromKind(token)); if (end >= text.length) { if (token === 8) { - var tokenText = _scanner.getTokenText(); - if (_scanner.isUnterminated()) { + var tokenText = scanner.getTokenText(); + if (scanner.isUnterminated()) { var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92) { @@ -31305,12 +33245,12 @@ var ts; } } else if (token === 3) { - if (_scanner.isUnterminated()) { + if (scanner.isUnterminated()) { result.finalLexState = 1; } } else if (ts.isTemplateLiteralKind(token)) { - if (_scanner.isUnterminated()) { + if (scanner.isUnterminated()) { if (token === 13) { result.finalLexState = 5; } @@ -31350,8 +33290,8 @@ var ts; case 25: case 26: case 27: + case 87: case 86: - case 85: case 28: case 29: case 30: @@ -31361,18 +33301,18 @@ var ts; case 44: case 48: case 49: - case 62: - case 61: case 63: - case 58: + case 62: + case 64: case 59: case 60: - case 53: + case 61: case 54: case 55: case 56: case 57: - case 52: + case 58: + case 53: case 23: return true; default: @@ -31393,38 +33333,38 @@ var ts; } } function isKeyword(token) { - return token >= 65 && token <= 124; + return token >= 66 && token <= 125; } function classFromKind(token) { if (isKeyword(token)) { - return 1; + return TokenClass.Keyword; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 2; + return TokenClass.Operator; } - else if (token >= 14 && token <= 63) { - return 0; + else if (token >= 14 && token <= 64) { + return TokenClass.Punctuation; } switch (token) { case 7: - return 6; + return TokenClass.NumberLiteral; case 8: - return 7; + return TokenClass.StringLiteral; case 9: - return 8; + return TokenClass.RegExpLiteral; case 6: case 3: case 2: - return 3; + return TokenClass.Comment; case 5: case 4: - return 4; - case 64: + return TokenClass.Whitespace; + case 65: default: if (ts.isTemplateLiteralKind(token)) { - return 7; + return TokenClass.StringLiteral; } - return 5; + return TokenClass.Identifier; } } return { getClassificationsForLine: getClassificationsForLine }; @@ -31442,7 +33382,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 221 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 224 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -31458,6 +33398,9 @@ var ts; } initializeServices(); })(ts || (ts = {})); +// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. +// See LICENSE.txt in the project root for complete license information. +/// var ts; (function (ts) { var BreakpointResolver; @@ -31496,98 +33439,101 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return spanInPreviousNode(node); } - if (node.parent.kind === 181) { + if (node.parent.kind === 183) { return textSpan(node); } - if (node.parent.kind === 167 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 169 && node.parent.operatorToken.kind === 23) { return textSpan(node); } - if (node.parent.kind == 161 && node.parent.body == node) { + if (node.parent.kind == 163 && node.parent.body == node) { return textSpan(node); } } switch (node.kind) { - case 175: + case 177: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 193: - case 130: - case 129: - return spanInVariableDeclaration(node); - case 128: - return spanInParameterDeclaration(node); case 195: case 132: case 131: + return spanInVariableDeclaration(node); + case 129: + return spanInParameterDeclaration(node); + case 197: case 134: - case 135: case 133: - case 160: - case 161: + case 136: + case 137: + case 135: + case 162: + case 163: return spanInFunctionDeclaration(node); - case 174: + case 176: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 201: + case 203: return spanInBlock(node); - case 217: + case 220: return spanInBlock(node.block); - case 177: + case 179: return textSpan(node.expression); - case 186: + case 188: return textSpan(node.getChildAt(0), node.expression); + case 182: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 181: + return spanInNode(node.statement); + case 194: + return textSpan(node.getChildAt(0)); case 180: return textSpan(node, ts.findNextToken(node.expression, node)); - case 179: - return spanInNode(node.statement); - case 192: - return textSpan(node.getChildAt(0)); - case 178: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 189: - return spanInNode(node.statement); - case 185: - case 184: - return textSpan(node.getChildAt(0), node.label); - case 181: - return spanInForStatement(node); - case 182: - case 183: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 188: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 214: - case 215: - return spanInNode(node.statements[0]); case 191: - return spanInBlock(node.tryBlock); + return spanInNode(node.statement); + case 187: + case 186: + return textSpan(node.getChildAt(0), node.label); + case 183: + return spanInForStatement(node); + case 184: + case 185: + return textSpan(node, ts.findNextToken(node.expression, node)); case 190: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 217: + case 218: + return spanInNode(node.statements[0]); + case 193: + return spanInBlock(node.tryBlock); + case 192: return textSpan(node, node.expression); - case 209: + case 211: + if (!node.expression) { + return undefined; + } return textSpan(node, node.expression); - case 203: + case 205: return textSpan(node, node.moduleReference); - case 204: + case 206: return textSpan(node, node.moduleSpecifier); - case 210: + case 212: return textSpan(node, node.moduleSpecifier); - case 200: + case 202: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 196: - case 199: - case 220: - case 155: - case 156: - return textSpan(node); - case 187: - return spanInNode(node.statement); - case 197: case 198: + case 201: + case 223: + case 157: + case 158: + return textSpan(node); + case 189: + return spanInNode(node.statement); + case 199: + case 200: return undefined; case 22: case 1: @@ -31607,17 +33553,17 @@ var ts; case 25: case 24: return spanInGreaterThanOrLessThanToken(node); - case 99: + case 100: return spanInWhileKeyword(node); - case 75: - case 67: - case 80: + case 76: + case 68: + case 81: return spanInNextNode(node); default: - if (node.parent.kind === 218 && node.parent.name === node) { + if (node.parent.kind === 221 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 158 && node.parent.type === node) { + if (node.parent.kind === 160 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -31627,12 +33573,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 182 || - variableDeclaration.parent.parent.kind === 183) { + if (variableDeclaration.parent.parent.kind === 184 || + variableDeclaration.parent.parent.kind === 185) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 175; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 181 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 177; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 183 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -31678,7 +33624,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 196 && functionDeclaration.kind !== 133); + (functionDeclaration.parent.kind === 198 && functionDeclaration.kind !== 135); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -31698,23 +33644,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 200: + case 202: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 180: - case 178: case 182: - case 183: + case 180: + case 184: + case 185: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 181: + case 183: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 194) { + if (forStatement.initializer.kind === 196) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -31733,34 +33679,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 199: + case 201: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 196: + case 198: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 202: + case 204: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 201: + case 203: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 199: - case 196: + case 201: + case 198: return textSpan(node); - case 174: + case 176: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 217: + case 220: return spanInNode(node.parent.statements[node.parent.statements.length - 1]); ; - case 202: + case 204: var caseBlock = node.parent; var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1]; if (lastClause) { @@ -31772,24 +33718,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 160: - case 195: - case 161: - case 132: - case 131: + case 162: + case 197: + case 163: case 134: - case 135: case 133: - case 180: - case 179: + case 136: + case 137: + case 135: + case 182: case 181: + case 183: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -31797,19 +33743,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 218) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 221) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 158) { + if (node.parent.kind === 160) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 179) { + if (node.parent.kind === 181) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -31819,6 +33765,21 @@ var ts; BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); })(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// var debugObjectHost = this; var ts; (function (ts) { @@ -32103,6 +34064,12 @@ var ts; return _this.languageService.getReferencesAtPosition(fileName, position); }); }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { + return _this.languageService.findReferences(fileName, position); + }); + }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { @@ -32312,3 +34279,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); +var toolsVersion = "1.4"; diff --git a/bin/typescriptServices_internal.d.ts b/bin/typescriptServices_internal.d.ts index 7fba731f25e..692c34786ec 100644 --- a/bin/typescriptServices_internal.d.ts +++ b/bin/typescriptServices_internal.d.ts @@ -41,6 +41,10 @@ declare module ts { */ function lastOrUndefined(array: T[]): T; function binarySearch(array: number[], value: number): number; + function reduceLeft(array: T[], f: (a: T, x: T) => T): T; + function reduceLeft(array: T[], f: (a: U, x: T) => U, initial: U): U; + function reduceRight(array: T[], f: (a: T, x: T) => T): T; + function reduceRight(array: T[], f: (a: U, x: T) => U, initial: U): U; function hasProperty(map: Map, key: string): boolean; function getProperty(map: Map, key: string): T; function isEmpty(map: Map): boolean; @@ -49,7 +53,6 @@ declare module ts { function forEachValue(map: Map, callback: (value: T) => U): U; function forEachKey(map: Map, callback: (key: string) => U): U; function lookUp(map: Map, key: string): T; - function mapToArray(map: Map): T[]; function copyMap(source: Map, target: Map): void; /** * Creates a map from the elements of an array. @@ -184,7 +187,7 @@ declare module ts { function isConst(node: Node): boolean; function isLet(node: Node): boolean; function isPrologueDirective(node: Node): boolean; - function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[]; + function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; let fullTripleSlashReferencePathRegEx: RegExp; function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; @@ -195,6 +198,10 @@ declare module ts { function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; function getSuperContainer(node: Node, includeFunctions: boolean): Node; function getInvokedExpression(node: CallLikeExpression): Expression; + function nodeCanBeDecorated(node: Node): boolean; + function nodeIsDecorated(node: Node): boolean; + function childIsDecorated(node: Node): boolean; + function nodeOrChildIsDecorated(node: Node): boolean; function isExpression(node: Node): boolean; function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; function isExternalModuleImportEqualsDeclaration(node: Node): boolean; @@ -211,7 +218,9 @@ declare module ts { function isInAmbientContext(node: Node): boolean; function isDeclaration(node: Node): boolean; function isStatement(n: Node): boolean; + function isClassElement(n: Node): boolean; function isDeclarationName(name: Node): boolean; + function isAliasSymbolDeclaration(node: Node): boolean; function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode; function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray; function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; @@ -270,7 +279,6 @@ declare module ts { function nodeStartsNewLexicalEnvironment(n: Node): boolean; function nodeIsSynthesized(node: Node): boolean; function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node; - function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string; /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) @@ -278,6 +286,38 @@ declare module ts { */ function escapeString(s: string): string; function escapeNonAsciiCharacters(s: string): string; + interface EmitTextWriter { + write(s: string): void; + writeTextOfNode(sourceFile: SourceFile, node: Node): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + getText(): string; + rawWrite(s: string): void; + writeLiteral(s: string): void; + getTextPos(): number; + getLine(): number; + getColumn(): number; + getIndent(): number; + } + function getIndentString(level: number): string; + function getIndentSize(): number; + function createTextWriter(newLine: String): EmitTextWriter; + function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; + function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; + function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void; + function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; + function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration; + function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean; + function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): { + firstAccessor: AccessorDeclaration; + secondAccessor: AccessorDeclaration; + getAccessor: AccessorDeclaration; + setAccessor: AccessorDeclaration; + }; + function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void; + function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void; + function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void; } declare module ts { var optionDeclarations: CommandLineOption[]; @@ -297,7 +337,10 @@ declare module ts { function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; + function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; + function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; function findListItemInfo(node: Node): ListItemInfo; + function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; function findContainingList(node: Node): Node; function getTouchingWord(sourceFile: SourceFile, position: number): Node; @@ -320,9 +363,11 @@ declare module ts { function getNodeModifiers(node: Node): string; function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; function isToken(n: Node): boolean; + function isWord(kind: SyntaxKind): boolean; function isComment(kind: SyntaxKind): boolean; function isPunctuation(kind: SyntaxKind): boolean; function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; + function isAccessibilityModifier(kind: SyntaxKind): boolean; function compareDataObjects(dst: any, src: any): boolean; } declare module ts { @@ -333,6 +378,7 @@ declare module ts { function keywordPart(kind: SyntaxKind): SymbolDisplayPart; function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; function operatorPart(kind: SyntaxKind): SymbolDisplayPart; + function textOrKeywordPart(text: string): SymbolDisplayPart; function textPart(text: string): SymbolDisplayPart; function lineBreakPart(): SymbolDisplayPart; function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; diff --git a/bin/typescript_internal.d.ts b/bin/typescript_internal.d.ts index 2d5973e5877..845f01eb360 100644 --- a/bin/typescript_internal.d.ts +++ b/bin/typescript_internal.d.ts @@ -41,6 +41,10 @@ declare module "typescript" { */ function lastOrUndefined(array: T[]): T; function binarySearch(array: number[], value: number): number; + function reduceLeft(array: T[], f: (a: T, x: T) => T): T; + function reduceLeft(array: T[], f: (a: U, x: T) => U, initial: U): U; + function reduceRight(array: T[], f: (a: T, x: T) => T): T; + function reduceRight(array: T[], f: (a: U, x: T) => U, initial: U): U; function hasProperty(map: Map, key: string): boolean; function getProperty(map: Map, key: string): T; function isEmpty(map: Map): boolean; @@ -49,7 +53,6 @@ declare module "typescript" { function forEachValue(map: Map, callback: (value: T) => U): U; function forEachKey(map: Map, callback: (key: string) => U): U; function lookUp(map: Map, key: string): T; - function mapToArray(map: Map): T[]; function copyMap(source: Map, target: Map): void; /** * Creates a map from the elements of an array. @@ -184,7 +187,7 @@ declare module "typescript" { function isConst(node: Node): boolean; function isLet(node: Node): boolean; function isPrologueDirective(node: Node): boolean; - function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[]; + function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; let fullTripleSlashReferencePathRegEx: RegExp; function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; @@ -195,6 +198,10 @@ declare module "typescript" { function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; function getSuperContainer(node: Node, includeFunctions: boolean): Node; function getInvokedExpression(node: CallLikeExpression): Expression; + function nodeCanBeDecorated(node: Node): boolean; + function nodeIsDecorated(node: Node): boolean; + function childIsDecorated(node: Node): boolean; + function nodeOrChildIsDecorated(node: Node): boolean; function isExpression(node: Node): boolean; function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; function isExternalModuleImportEqualsDeclaration(node: Node): boolean; @@ -211,7 +218,9 @@ declare module "typescript" { function isInAmbientContext(node: Node): boolean; function isDeclaration(node: Node): boolean; function isStatement(n: Node): boolean; + function isClassElement(n: Node): boolean; function isDeclarationName(name: Node): boolean; + function isAliasSymbolDeclaration(node: Node): boolean; function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode; function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray; function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; @@ -270,7 +279,6 @@ declare module "typescript" { function nodeStartsNewLexicalEnvironment(n: Node): boolean; function nodeIsSynthesized(node: Node): boolean; function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node; - function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string; /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) @@ -278,6 +286,38 @@ declare module "typescript" { */ function escapeString(s: string): string; function escapeNonAsciiCharacters(s: string): string; + interface EmitTextWriter { + write(s: string): void; + writeTextOfNode(sourceFile: SourceFile, node: Node): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + getText(): string; + rawWrite(s: string): void; + writeLiteral(s: string): void; + getTextPos(): number; + getLine(): number; + getColumn(): number; + getIndent(): number; + } + function getIndentString(level: number): string; + function getIndentSize(): number; + function createTextWriter(newLine: String): EmitTextWriter; + function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; + function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; + function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void; + function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; + function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration; + function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean; + function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): { + firstAccessor: AccessorDeclaration; + secondAccessor: AccessorDeclaration; + getAccessor: AccessorDeclaration; + setAccessor: AccessorDeclaration; + }; + function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void; + function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void; + function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void; } declare module "typescript" { var optionDeclarations: CommandLineOption[]; @@ -297,7 +337,10 @@ declare module "typescript" { function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; + function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; + function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; function findListItemInfo(node: Node): ListItemInfo; + function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; function findContainingList(node: Node): Node; function getTouchingWord(sourceFile: SourceFile, position: number): Node; @@ -320,9 +363,11 @@ declare module "typescript" { function getNodeModifiers(node: Node): string; function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; function isToken(n: Node): boolean; + function isWord(kind: SyntaxKind): boolean; function isComment(kind: SyntaxKind): boolean; function isPunctuation(kind: SyntaxKind): boolean; function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; + function isAccessibilityModifier(kind: SyntaxKind): boolean; function compareDataObjects(dst: any, src: any): boolean; } declare module "typescript" { @@ -333,6 +378,7 @@ declare module "typescript" { function keywordPart(kind: SyntaxKind): SymbolDisplayPart; function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; function operatorPart(kind: SyntaxKind): SymbolDisplayPart; + function textOrKeywordPart(text: string): SymbolDisplayPart; function textPart(text: string): SymbolDisplayPart; function lineBreakPart(): SymbolDisplayPart; function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; From d15278bb864ebcec685f3e7d068941cdf70260f2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 27 Mar 2015 15:53:01 -0700 Subject: [PATCH 09/10] Fix: File watchers not being disposed in -watch mode --- src/compiler/tsc.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a0d21106f43..0cbeff8204a 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -276,6 +276,7 @@ module ts { // If a source file changes, mark it as unwatched and start the recompilation timer function sourceFileChanged(sourceFile: SourceFile) { + sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; startTimer(); } From a8e4f27e50448579e7775bfe0eaf442c3573e5fd Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 27 Mar 2015 16:12:19 -0700 Subject: [PATCH 10/10] Address code review --- src/harness/loggedIO.ts | 2 +- src/harness/rwcRunner.ts | 41 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index b4c88898a51..8ba38043e78 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -15,7 +15,7 @@ interface IOLog { arguments: string[]; executingPath: string; currentDirectory: string; - useDefaultLibFile?: boolean; + useCustomLibraryFile?: boolean; filesRead: { path: string; codepage: number; diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 1578d0665ca..49a15112e9f 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -32,7 +32,7 @@ module RWC { }; var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; var currentDirectory: string; - var useDefaultLibFile: boolean; + var useCustomLibraryFile: boolean; after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. @@ -44,10 +44,10 @@ module RWC { baselineOpts = undefined; baseName = undefined; currentDirectory = undefined; - // useDefaultLibFile is a flag specified in the json object to indicate whether to use built/local/lib.d.ts - // or to use lib.d.ts inside the json object. If the flag is true or undefine, use the build/local/lib.d.ts - // otherwise use the lib.d.ts from the json object. - useDefaultLibFile = undefined; + // useCustomLibraryFile is a flag specified in the json object to indicate whether to use built/local/lib.d.ts + // or to use lib.d.ts inside the json object. If the flag is true, use the lib.d.ts inside json file + // otherwise use the lib.d.ts from built/local + useCustomLibraryFile = undefined; }); it('can compile', () => { @@ -56,10 +56,7 @@ module RWC { var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); currentDirectory = ioLog.currentDirectory; - useDefaultLibFile = ioLog.useDefaultLibFile; - if (useDefaultLibFile === undefined) { - useDefaultLibFile = true; - } + useCustomLibraryFile = ioLog.useCustomLibraryFile; runWithIOLog(ioLog, () => { opts = ts.parseCommandLine(ioLog.arguments); assert.equal(opts.errors.length, 0); @@ -78,32 +75,33 @@ module RWC { }); // Add files to compilation - ts.forEach(ioLog.filesRead, fileRead => { + for(let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); - var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath); + var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath); if (!Harness.isLibraryFile(fileRead.path)) { - if (!inInputList) { - otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); + if (inInputList) { + continue; } + otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)){ if (!inInputList) { - // If useDefaultLibFile is true, we will use built/local/lib.d.ts - // instead of the provided lib.d.ts from json object. + // If useCustomLibraryFile is true, we will use lib.d.ts from json object + // otherwise use the lib.d.ts from built/local // Majority of RWC code will be using built/local/lib.d.ts instead of // lib.d.ts inside json file. However, some RWC cases will still use // their own version of lib.d.ts because they have customized lib.d.ts - if (useDefaultLibFile) { - inputFiles.push(Harness.getDefaultLibraryFile()); + if (useCustomLibraryFile) { + inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } else { - inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); + inputFiles.push(Harness.getDefaultLibraryFile()); } } } - }); + } // do not use lib since we already read it in above opts.options.noLib = true; @@ -140,7 +138,10 @@ module RWC { it('has the expected declaration file content', () => { Harness.Baseline.runBaseline('has the expected declaration file content', baseName + '.d.ts', () => { - if (!compilerResult.declFilesCode.length) { return null; } + if (!compilerResult.declFilesCode.length) { + return null; + } + return Harness.Compiler.collateOutputs(compilerResult.declFilesCode); }, false, baselineOpts); });